It’s all hands OFF deck with this Pi-powered LEGO card shuffler
Who needs to laboriously shuffle their own deck when Raspberry Pi can do it for you? In the latest issue of The MagPi, our recent intern, Louis Wood, tells us all about the nifty LEGO card shuffler he designed during his summer spent in the Maker Lab.
Maker and Cambridge engineering undergraduate Louis Wood first encountered Raspberry Pi while looking for a low-cost microcontroller that could be programmed with Python for an A-level project. Inspiring plenty of envy, he’s just spent six whole weeks ensconced in Raspberry Pi HQ’s very own maker space building a range of Raspberry Pi projects, including a LEGO card shuffler. Basing it around the LEGO Build HAT helped him evolve and improve upon a design that he and his Queens’ College Cambridge friends, Lucas Hoffman and Emily Wang, devised. The card shuffler idea was their response to a design and build challenge, based around a LEGO NXT system, to demonstrate an aspect of engineering science. The dual-motor design was in need of some reworking, which Louis undertook while working as an intern at Raspberry Pi Towers alongside Maker in Residence Toby Roberts.
Quirky and cool
Louis used a LEGO Spike education kit with Raspberry Pi’s LEGO Build HAT to create a simpler but more robust design. The kit includes cycle motors, which he attached directly to the Build HAT’s four connectors. “The Build HAT made it pretty easy to pick up all the motors and plug them in.” He then programmed Raspberry Pi 4 over SSH, “which made it easy to tweak code.”
The MicroPython code produces either a one or a zero and spins either the left or right motor accordingly: “When the motor turns on, the wheel spins a few cards into the middle.” The motors run on a loop, each powering on for a second or two, pushing cards from each side and randomly shuffling them into a central pile until the Build HAT colour sensors detect the black base of either card bay. The card shuffler then skips that side and only runs the opposite motor for a while to clear the rest of the cards. Once it notices it’s done shuffling, it stops.
The build took a couple of hours, and Louis spent a similar time coding and tweaking the build. “The hardest thing was making it so that it doesn’t just spit out the whole side [of cards] at once,” he says.
His simple-but-effective barrier is positioned such that only a single card at a time can (usually) be shuffled along by the motor. The setup doesn’t always work flawlessly, occasionally requiring the user to deftly flick a card back into place, but Louis aims to improve the design by moving apart the two card holding sides to prevent blockages.
The Build HAT came into its own thanks to the colour sensor Raspberry Pi 4 used to detect whether there were still cards awaiting shuffling. The white background of the cards contrasted with the black base of the crates he’d created, which was visible only when the stack of cards was depleted. Other card decks — such as Uno ones, which usually have a black background — could be shuffled too, as long as the card holder base colour was changed.
Makers gonna make
Two weeks into his internship, Louis had already created and written about a ‘Pixie’ tube clock and had been building “a Raspberry Pi mount and cooling system for one of the engineers upstairs, so you can sort of be running eight Raspberry Pis at the same time, fans, and an enclosure,” as well as a remote control based on the brand-new Pico 2.
Given this prodigious rate of design, we asked whether an engineering career or one as a maker is in his future. “I’d like to be a maker, but I think it’s quite hard…” Louis said. “To be a maker YouTuber takes a lot of work and time, I think… probably a bit risky.”
Read the full story, including some extra tips and projects from maker Louis Wood, in The MagPi #146.
The MagPi #146 out NOW!
You can grab the new issue right now from Tesco, Sainsbury’s, Asda, WHSmith, and other newsagents, including the Raspberry Pi Store in Cambridge. It’s also available at our online store, which ships around the world. You can also get it via our app on Android or iOS.
You can also subscribe to the print version of The MagPi. Not only do we deliver it globally, but people who sign up to the six- or twelve-month print subscription get a FREE Raspberry Pi Pico W!
The post It’s all hands OFF deck with this Pi-powered LEGO card shuffler appeared first on Raspberry Pi.