This project is my implementation of an alien themed slot machine using two ATmega328P-PU micro-controllers. The slot machine is for entertainment and educational purposes only. I tried my best to make the game simulate a real slot machine as closely as possible. The project is completely built. An enclosure was added after the parts arrived from China and I soldered everything up. The project took about a month for me to build in my spare time. The most difficult part of the build for me was understanding all of the math involved in making the game behave the way the casino industry would expect a simple slot machine it to behave, and being able to prove it.
Step 1: How the Game Works
The game has three reels with the same unique 25 symbols appearing on each reel (one of the 8×8 matrices on the component with 4 8×8 matrices isn’t used.) There are five different ways to win. If you get three spaceships, you win the jackpot. If you get one or two spaceships you also win some credits. If you get two or three symbols to match you also win. If you get a spaceship and two symbols matching, as depicted below, the game pays out based on the winning event with the lowest probability/highest payout; in other words winning events are mutually exclusive, you can’t win two different ways on a single spin of the reels. This kept the programming a little simpler. There were plenty of other challenges for me.
Step 2: Slot Machine Menu & Features
The slot machine has several interesting features which are accessed via the 20 x 4 I2C capable LCD display using two navigation buttons and a select button. The buttons use a fairly sophisticated de-bouncing algorithm that takes advantage of the micro-controller’s external interrupt capability. This is the main menu.
Since there are six lines in the menu you have to scroll down using the ‘navigate down’ button to see the entire menu. There is a lever/knife switch dedicated to ‘spinning’ the reels. In addition to that you can also select ‘Play’ from the main menu. You can change your bet at any time.
The most exciting feature is that the game can be played in ‘auto’ mode; i.e. you select the auto mode option from the settings menu on the LCD screen and the game plays over and over again until you select the option again or 1 million plays have occurred. This is a critical function for testing the game. You can also disable the sound here.
Via the menu on the LCD it’s also possible to view all of the metrics generated from the simulation. These metrics are also output and may be viewed in the serial monitor if you connect your micro-controller to the monitor via the RX and TX pins using a USB cable. The list of displayed metrics includes your credit balance, the number of times you hit the jackpot, and the number of times you won credits by any other means. This allowed me to run simulations based on the various payouts, and was useful for establishing and proving out the payout table. The payout table itself is not configurable; once it is set it should stay the same. I suppose it would be possible to make the volatility index configurable by using it to drive the payout tables, but that would require a lot more work.
The Reset option allows you to reset all of the metrics (except EEprom writes), back to zero. The chip will work for about 100,000 writes to EEprom. Since there’s 512k of EEprom available on the chip, and we’re only using a fraction of that, it would be possible to actually move the location of the metrics in EEprom as we approach 100,000 writes. I have not implemented this feature but it would be a means by which to extend the life of the chip.
Finally, the hold, or the percentage of each wager kept by the house (over time), is configurable. Remember that after performing a Reset operation the hold needs to be set again.
Source: Arduino Slot Machine