Skip to main content
Version: ACS CC

Slot Machine

A mini slot machine that accepts real coins, spins three physical reels, and dispenses a payout on win.

info

Author: Teodor Adrian Miron
GitHub Project Link: https://github.com/UPB-PMRust-Students/acs-project-2026-teodoradriann

Description

My project consists in building a mini Slot Machine where you can insert coins and bet X amount of credited money. The system uses a load cell to count coins and three stepper motors to physically roll the reels. The game is initiated via a dedicated Spin button, and if the player wins, the amount is dispensed physically using a servo-driven payout mechanism.

Motivation

I wanted to do something fun and help students control their gambling addiction with tiny amounts of money.

Architecture

The software architecture is based on a Finite State Machine (FSM) managing the game flow, implemented in Rust using the Embassy framework for async multitasking.

  • The main components (architecture components, not hardware components):
    • Core Logic / State Machine: manages game states (IDLE, WAITING_FOR_BET, SPINNING, PAYOUT) and coordinates all modules.
    • Input / Sensor Manager: handles debouncing for the Spin and Bet buttons and interprets weight signals from the load cell.
    • Random Number Generator (RNG): responsible for the fair generation of the spin outcome.
    • Motor / Actuator Controller: translates the RNG result into steps for the 3 stepper motors and PWM signals for the payout servo.
    • Display / UI Controller: manages the ST7735 LCD, displaying credit balance and bet amount.
    • Payout Manager: commands the servo motor to eject the coins.
  • How they connect with each other:
    • The Input Manager detects a coin (weight increase) or a button press and sends an event to the Core Logic.
    • Core Logic updates the credit and instructs the Display Controller to refresh.
    • When the Spin button is pressed, Core Logic switches to the SPINNING state and requests a value from the RNG.
    • The Motor Controller starts the 3 stepper motors and stops them sequentially based on the RNG result.
    • If a win is detected, the Payout Manager activates the servo to slide coins out of the storage tube.

Log

Week 5 - 11 May

Week 12 - 18 May

Week 19 - 25 May

Hardware

The build uses a microcontroller board driving a small TFT display, an HX711 + load cell pair for detecting inserted coins by weight, three 28BYJ-48 stepper motors with ULN2003 drivers for the physical reels, a continuous-rotation servo for the payout mechanism, arcade buttons for player input, and a 5 V stabilized power supply to handle motor peak currents.

Schematics

Place your KiCAD or similar schematics here in SVG format.

Bill of Materials

DeviceUsagePrice
DS04-NFC Continous Rotation ServoDrives the coin payout mechanism39 RON
5 V 5000 mA Stabilized Power SupplyPowers the motors and the rest of the system30 RON
1.44" SPI LCD Module with ST7735 Controller (128x128 px)Displays credit balance, bet amount and reel animation30 RON
ULN2003 Stepper Driver + 5V Stepper Motor (x3)Physically rolls the three reels17 RON
Arcade Button 24 mm - GreenSpin / bet input from the player10 RON
HX711 GroundStudio Load Cell AmplifierReads digital weight values from the load cell11 RON
Load Cell (max. 1 Kg)Detects inserted coins by weight10 RON

Software

LibraryDescriptionUsage
embassy-stm32STM32 hardware driverControlling pins, timers (PWM for the servo) and SPI for the LCD
embassy-timeTime and delay managementNon-blocking delays for stepper motor steps and animations
embassy-executorAsync task schedulerRunning multiple tasks (motors, UI, sensors) concurrently
embassy-syncAsync sync primitivesInter-task communication (e.g. sending coin weight data to the UI)
cortex-mCore processor accessManaging interrupts and CPU-specific instructions
cortex-m-rtStartup/Runtime for ARMInitializing memory and the program entry point
defmtLow-overhead loggerFast logging for debugging sensor data and game states
defmt-rttRTT transport for logsViewing logs in real-time through the debugger
embedded-graphics2D graphics libraryDrawing fruit icons, text and shapes on the screen
st7735-lcdDisplay driver for ST7735Managing the command set for the 1.44" color TFT screen
hx711Load cell driverReading digital weight values from the load cell amplifier
panic-probeDebug panic handlerReporting and stopping the CPU safely if a runtime crash occurs
  1. Slot machine reference video