Slot Machine
A mini slot machine that accepts real coins, spins three physical reels, and dispenses a payout on win.
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.
- Core Logic / State Machine: manages game states (
- 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
SPINNINGstate 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
| Device | Usage | Price |
|---|---|---|
| DS04-NFC Continous Rotation Servo | Drives the coin payout mechanism | 39 RON |
| 5 V 5000 mA Stabilized Power Supply | Powers the motors and the rest of the system | 30 RON |
| 1.44" SPI LCD Module with ST7735 Controller (128x128 px) | Displays credit balance, bet amount and reel animation | 30 RON |
| ULN2003 Stepper Driver + 5V Stepper Motor (x3) | Physically rolls the three reels | 17 RON |
| Arcade Button 24 mm - Green | Spin / bet input from the player | 10 RON |
| HX711 GroundStudio Load Cell Amplifier | Reads digital weight values from the load cell | 11 RON |
| Load Cell (max. 1 Kg) | Detects inserted coins by weight | 10 RON |
Software
| Library | Description | Usage |
|---|---|---|
| embassy-stm32 | STM32 hardware driver | Controlling pins, timers (PWM for the servo) and SPI for the LCD |
| embassy-time | Time and delay management | Non-blocking delays for stepper motor steps and animations |
| embassy-executor | Async task scheduler | Running multiple tasks (motors, UI, sensors) concurrently |
| embassy-sync | Async sync primitives | Inter-task communication (e.g. sending coin weight data to the UI) |
| cortex-m | Core processor access | Managing interrupts and CPU-specific instructions |
| cortex-m-rt | Startup/Runtime for ARM | Initializing memory and the program entry point |
| defmt | Low-overhead logger | Fast logging for debugging sensor data and game states |
| defmt-rtt | RTT transport for logs | Viewing logs in real-time through the debugger |
| embedded-graphics | 2D graphics library | Drawing fruit icons, text and shapes on the screen |
| st7735-lcd | Display driver for ST7735 | Managing the command set for the 1.44" color TFT screen |
| hx711 | Load cell driver | Reading digital weight values from the load cell amplifier |
| panic-probe | Debug panic handler | Reporting and stopping the CPU safely if a runtime crash occurs |