Home > Blog > Arduino Slot Machine

Arduino Slot Machine

Summary of Arduino Slot Machine


This article details an alien-themed slot machine project built with two ATmega328P-PU microcontrollers for entertainment and education. The game features three reels, 25 unique symbols, and five distinct winning conditions based on spaceship matches. It includes a 20x4 I2C LCD display controlled by navigation and select buttons, plus a lever/knife switch for spinning. Key features include adjustable bet amounts, an auto-play mode capable of one million spins, sound toggling, and real-time metric tracking via serial monitor. The build emphasizes mathematical accuracy to simulate casino payout behaviors and uses EEPROM for data persistence.

Parts used in the Alien Themed Slot Machine:

  • Two ATmega328P-PU micro-controllers
  • 20 x 4 I2C capable LCD display
  • Two navigation buttons
  • One select button
  • Lever/knife switch
  • USB cable
  • EEPROM memory (512k available)
https://youtu.be/UDwan_kk5Yc

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

Quick Solutions to Questions related to Alien Themed Slot Machine:

  • How many micro-controllers are used in this project?
    The project uses two ATmega328P-PU micro-controllers.
  • What is the maximum number of plays in auto mode?
    The game can play over and over again until 1 million plays have occurred.
  • How many unique symbols appear on each reel?
    There are 25 unique symbols appearing on each reel.
  • Can the hold percentage be changed?
    Yes, the hold or percentage kept by the house is configurable via the menu.
  • Does the chip support unlimited EEPROM writes?
    No, the chip will work for about 100,000 writes to EEPROM.
  • How do you access the game metrics?
    Metrics can be viewed on the LCD screen or output to a serial monitor via RX and TX pins using a USB cable.
  • What happens if you get a spaceship and two matching symbols?
    The game pays out based on the winning event with the lowest probability or highest payout.
  • Is the payout table configurable?
    No, the payout table is not configurable once it is set.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter
Scroll to Top