3x3 Casino Slot Machine

by 775598 in Circuits > Arduino

25 Views, 0 Favorites, 0 Comments

3x3 Casino Slot Machine

IMG_7622.jpg

This project is a 3x3 digital slot machine built with an Arduino Uno. It uses an LCD display, LEDs, switches, and a button to create a simple casino-style game. Players stop the reels one at a time and try to match symbols across rows and diagonals. A rigged mode is included for testing and demonstrating guaranteed winning combinations.

Downloads

Supplies

1 x Arduino Uno Microcontroller

1 x I2C LCD Display

6 x LEDs

6 x 330Ω Resistors

1 x Pushbutton

1 x 4 DIP Slide Switches

2 x 10kΩ Resistors

1 x Breadboard & wires

Connect the Inputs

IMG_7640.jpg
IMG_7641.jpg

Connect the Arduino's 5V and GND pins to the breadboard power rails. Place the push button on the breadboard and connect it to Pin 5 and GND. Install the DIP switches and connect them to Pins 2 and 3. These will be used as the power switch and the rigged mode switch.

Connect the LEDs

IMG_7639.jpg

Place 6 LEDs in a row on the breadboard. Connect each LED to Arduino Pins 6–11 and add a 330Ω resistor between each LED and GND. These LEDs create the spinning light effect during gameplay and flash when the player wins.

Connect the LCD Display

IMG_7642.jpg

Connect the LCD display to the Arduino using the I2C connections: VCC to 5V, VDD to GND, SDA to A4, and SCK to A5. Once everything is wired, upload the code to the Arduino. The display should show the slot machine interface, allowing the player to stop the reels and check for winning combinations.

The Code

image.jpg

To set up the libraries in the Arduino IDE, click the Library Manager icon on the left toolbar (or go to Tools then Manage Libraries...), search for Adafruit SSD1306, click Install, and choose Install All when the prompt appears to automatically grab the required Adafruit_GFX and Adafruit_BusIO graphics dependencies.

The main game data is stored in a 3x3 multi-dimensional array (grid[3][3]), which holds the symbol positions for each reel and makes it easier to manage the display and win checking.

Instead of using blocking delays like delay(), the program uses a non-blocking timing system with millis(), allowing the reels to animate and LEDs to update while still constantly checking for button presses and switch inputs.

Symbol outcomes are controlled using a weighted random system (reelMap), which adjusts probability so common symbols appear more often while rare symbols like 777 appear less frequently. This creates more realistic slot machine odds.

When a column is locked, the program updates one section of the grid at a time and uses a modulo offset safety check to avoid repeated symbols in the same column for a cleaner display.

Win detection is handled using Boolean logic comparisons across the grid, checking horizontal and diagonal lines. If matching symbols are found, the program adds the corresponding value from multipliers[] and counts it as a win.

Overall, the system is structured around modular game states and uses efficient embedded programming techniques to manage inputs, outputs, and display updates in real time.


https://docs.arduino.cc/language-reference/en/variables/data-types/array/

https://github.com/adafruit/Adafruit-GFX-Library

https://forum.arduino.cc/t/state-machines-a-short-tutorial/580593

https://academy.programmingelectronics.com/tutorial-18-state-change-detection-and-the-modulo-operator-old-version/