DoubleUp!
An interactive reaction and strategy game inspired by casino experiences.
Author: Bobelniceanu Darius-Andrei
GitHub Project Link: https://github.com/UPB-PMRust-Students/proiect-dariusbbl
Description
DoubleUp! is an interactive game where the user must react quickly and make strategic decisions to double their points.
-
The user presses the start button to begin the game.
-
In the first phase, a green LED lights up randomly within a preset interval (maximum 30 seconds). The user must quickly press the reaction button.
-
If the user presses in time, they enter the "doubling" mode; otherwise, a points penalty is applied.
-
In the doubling mode, the user bets points and chooses between two buttons (Red/Blue), each accompanied by a corresponding LED.
-
Each correct choice doubles the gain (x2, x4, x8), while an incorrect choice results in the loss of the bet.
-
The LCD display shows the current balance, user actions, and a history of the last 5 doubling rounds.
-
Specific sounds (inspired by Shining Crown game) are played for correct or incorrect actions via a dedicated audio module.
Motivation
DoubleUp! was born from my passion for interactive, fast-paced games and my interest in embedded programming. I wanted to create a project that not only challenges user reflexes but also brings a strategic layer to the gameplay.
Choosing Rust as the programming language was a natural decision, given its strong emphasis on performance, memory safety, and increasing relevance in embedded systems development.
Through this project, I aim to deepen my understanding of hardware-software integration, explore human-machine interaction concepts, and bring an engaging user experience to life by combining LEDs, displays, buttons, and authentic audio feedback.
Architecture
The architecture of DoubleUp! is centered around the following key components:
Raspberry Pi Pico 2W serves as the central microcontroller, managing all core functions of the system, such as controlling LEDs, handling user interactions, updating the display, and triggering audio feedback.
LCD SPI 128x160 display (ST7735) is connected via SPI interface and shows the user's balance, messages, and the history of the last 5 doubling actions.
LEDs (green, red, blue) provide immediate visual feedback to the user about game phases and choices.
DFPlayer Mini module handles the playback of preloaded .mp3 sound effects, offering an authentic audio experience for correct and incorrect actions.
MicroSD Card installed on the DFPlayer Mini stores the sound files needed for the different events during gameplay.
Speaker connected to the DFPlayer Mini outputs the sound effects during the game.
Level Converter (logic level shifter) ensures safe UART communication between the Raspberry Pi Pico (operating at 3.3V) and the DFPlayer Mini (operating at 5V), preventing damage to the microcontroller and ensuring reliable data transmission.
Log
Week - May
Week - May
Week - May
Hardware
- Raspberry Pi Pico 2W:
- Purpose: Central control unit.
- Function: Coordinates LEDs, buttons, LCD, and audio module.
- LCD SPI 128x160 (ST7735):
- Purpose: Displays text (balance, messages, history).
- Function: Displays real-time information such as the user's current score, system messages (e.g., "Start", "Correct", "Wrong"), and the history of the last 5 bets.
- Buttons:
- Purpose: Provide physical input for the user to interact with the game.
- Function: - Start Button: Initiates a new game session.
- Red/Black Buttons: Allow the player to make their bet selection during the doubling phase.
- LEDs:
- Purpose: Visual indication (start, red, blue).
- Function: Light up according to the game state.
- Green LED: Signals when the user must quickly react.
- Red and Blue LEDs: Represent the choices during the doubling phase.
- DFPlayer Mini:
- Purpose: Dedicated audio playback module.
- Function: Plays preloaded .mp3 sound effects stored on a MicroSD card to enhance the gaming experience with authentic casino sounds for correct or incorrect actions.
- MicroSD Card:
- Purpose: Storage medium for audio files.
- Function: Stores .mp3 files that are triggered during the gameplay events.
- Speaker (3W):
- Purpose: Sound output.
- Function: Outputs the audio files played by the DFPlayer Mini, providing clear feedback to the user.
- Level Converter (3.3V - 5V):
- Purpose: Voltage compatibility bridge between the Pico and the DFPlayer Mini.
- Function: Ensures safe signal levels when sending commands from the Pico (3.3V logic) to the DFPlayer (5V logic).
- Breadboard + Jumper Wires:
- Purpose: Prototyping and modular connection.
- Function: Facilitates quick setup, testing, and modification of the circuit during development.
- Current-Limiting Resistors:
- Purpose: Protect LEDs and microcontroller outputs.
- Function: Limits the amount of current flowing through each LED to safe levels.
Hardware Overview:
- Pico coordinates the entire system.
- LCD communicates the game state.
- LEDs signal visual actions.
- Buttons provide manual input.
- DFPlayer Mini plays authentic sounds.
- Level Converter ensures safe voltage communication.
Schematics
Bill of Materials
Device | Usage | Price |
---|---|---|
Rapspberry Pi Pico 2W | The microcontroller | 39,66 RON |
MicroSD 4GB | Sound Storage | 15 RON |
LCD Display | LCD Display | 25 RON |
DFPlayer Mini | Plays mp3 sounds | 13,99 RON |
Level Convertor | Converts from 3v3 to 5v | 15,99 RON |
Speaker | Converts from 3v3 to 5v | 7,00 RON |
Software
Library | Description | Usage |
---|---|---|
embassy-rp | RP2040 Peripherals | Used for accessing the peripherals |
[embedded-hal] | Hardware abstraction layer | Used to abstract common embedded traits like digital output, delay, SPI, etc. |
[embedded-graphics] | Drawing 2D graphics in embedded environments | Used to render text and visuals on the LCD |
[st7735-lcd] | Driver crate for ST7735 LCDs | Used to communicate with the LCD via SPI |
[dfplayer-mini] | UART-based MP3 module interface | Used to send commands like play, stop, volume to DFPlayer |
[defmt] | Lightweight logging framework for embedded Rust | Used for debugging and tracing game logic |
[fugit] | Time management | Used for scheduling delays and timeouts (e.g., LED reaction window) |