Zack Lee's blog

Midterm Project2

Posted at — Oct 31, 2019

Midterm2: Slot Machine

My team mate KJ and I built a slot machine for Halloween using an Arduino Nano 33 IoT. It uses three LED Matrices for reels and a Servo motor for the candy dispenser. Five images are used per reel that are seven, alien, dog, heart and skull. The case and parts are designed and 3d printed using the Tinkercad software.

Slot Machine Video :

Animation : We used a circle in and out easing function to make the reel spinning animation look natural.

Probability : Originally, we purely randomized the three reels which made the chance to win extremely low (about 4%) Therefore, we raised the chance by making the second and third reels to automatically try multiple times per game until their image matches with the first reel’s image.

For example, if the first reel’s image is seven, the second and third will try one more time if they didn’t get seven in the first place. And if the first reel’s image is heart, the second and third will try three more times until they get heart. If the first reel’s image is either alien, dog or skull, the second and third will try five more times until they get the same image.

Since it has the lowest chance to win with three sevens(a Jackpot), it will give out the most candies by making the Servo motor rotate five times. And three hearts will make the Servo motor rotate three times, three of the rest images will make the Servo motor rotate once giving out the least amount of candies.

Sound : For creating the sound effect when reels spin, we used a square waveform LFO to control pitch of the sound resulting in a digital phone ringing like sound. Also, we created a short melody which is played as candies are being dispensed from the slot machine.

Here’s the code used for the slot machine.

comments powered by Disqus