DIY Roulette Game Uses an ESP32 DevKit and a Ring of LEDs to Run This Classic Game of Chance
Element14 Presents host Mark Donners has created a miniature roulette table complete with realistic animations, sound, and fun gameplay.
Roulette tables
In nearly any casino, there are several staple tabletop games of chance that can be played in hopes of striking it big. Apart from blackjack, craps, poker, and pool, many are drawn to the roulette wheel due to its simplicity and the large variety of bets that can be made. The player starts by betting on single numbers, ranges/groups of numbers, or colors before the croupier releases the ball into the wheel and lets it settle into a single pocket. Depending on the number, the payout could range from 1-to-1 all the way to 35-to-1 for the riskiest bets, making it an excellent high-stakes game.
Wanting to build his own, much smaller version, element14 Presents host Mark Donners designed and constructed a fully digital version out of NeoPixel LEDs and an ESP32 DevKit.
The hardware
More intricate roulette wheels will still incorporate a spinning wheel in the center and a physical ball. However, this does not lend itself well to resets and quick setup/teardown, which is why Donners' version is largely static and solely uses LEDs to indicate the result. Beyond the lights and ESP32 DevKit microcontroller board, he also added a speaker, audio board, and a button for interactions with the player.
The ESP32 stores MP3 files in its internal SPIFFS filesystem, which means that through the I2S peripheral, sound data can be decoded and sent to the audio board quite easily. It also allows Donners to expand/modify the sounds his system plays with just a firmware update.
Animations
While the second core is dedicated to playing audio files, Donners utilized the first core of the ESP32 to control the LEDs. Within a loop, it first checks if the button has been pressed and made the game switch to an active state. Then once here, it begins an LED acceleration animation before looping a couple of times and selecting a random LED to stop on. Finally, it decelerates the LEDs and shows the final result of the spin.
Playing some roulette
After testing the code with the LEDs and sound board, Donners completed the project by cutting out a hole for the speaker in the center of the enclosure and then surrounding it with a roulette wheel decal and the ring of LEDs. Playing the game was as easy as pressing the button and watching as the virtual ball suspensefully spun around until ending up at its final resting position.
To see more about how Donners create this mini version of roulette, you can watch his video here on the element14 Presents YouTube channel.