BlackJack Machine
A singleplayer card game powered by a Raspberry Pi Pico 2 and Rust.
Author: Stavăr Laurențiu-Cristian
GitHub Project Link: https://github.com/UPB-PMRust-Students/proiect-StavarLaurentiu
Description
A fully interactive BlackJack game machine built on a Raspberry Pi Pico 2 - RP2350A, using the Rust programming language and Embassy async framework.
Features:
- Uses three buttons for game actions: HIT, STAND and START GAME.
- Displays dealer and player cards across 8 OLED 0.96" screens.
- Includes 1 OLED 0.96" display dedicated to real-time game state messages.
- Uses 2 RGB LEDs to indicate turns and round outcomes.
- Utilizes a TCA9548A I2C multiplexer to manage identical OLED addresses.
- Executes full BlackJack logic: card drawing, user input, dealer logic, and win conditions.
Motivation
This project combines microcontroller programming, real-time interaction, and game logic design. My goal was to build something fun and visually interactive, while pushing the limits of what I learned in embedded systems and Rust. The integration of I2C multiplexing, OLED control, and user inputs made this an ideal project to consolidate theory into a challenging and rewarding practical application.
Architecture
The Raspberry Pi Pico 2 - RP2350A acts as the central unit, managing peripherals and orchestrating the game flow.
- Buttons (GPIO): detect user input (HIT / STAND / START GAME).
- RGB LEDs (PWM): blink or hold to indicate whose turn or the round outcome.
- 9 OLED Display 0.96"s (I2C): show player/dealer cards and the game state.
- TCA9548A I2C MUX: used to route communication between the Pico and the OLEDs sharing the same I2C address.
Game Flow Summary:
- Startup: OLED instructs user to press START.
- Dealer draws 2 cards – LED blinks – game state updates.
- Player draws 2 cards – LED blinks – game state updates.
- Player phase: can HIT (get card) or STAND (end turn).
- If player busts: game ends.
- Else: dealer draws to at least 17.
- Compare scores: show result and reset after 5 seconds.
LED & OLED Usage
- Blinking LEDs indicate active turn.
- Solid yellow LED indicates winner or draw.
- OLEDs visually show each card and game progress.
Block Scheme
Log
Week 5 – 11 May
TO DO
Week 12 – 18 May
TO DO
Week 19 – 25 May
TO DO
Hardware
-
Raspberry Pi Pico 2 - RP2350A
- Main microcontroller; handles game logic, I2C communication, and peripheral control.
-
2 Push Buttons (HIT & STAND)
- User input; GPIO with pull-ups.
-
2 RGB LEDs
- Visual indicators for player/dealer turn and result status.
-
9 OLED 0.96" Displays (128x64)
- Display game content (cards and messages). All share the same I2C address.
-
TCA9548A I2C Multiplexer
- Routes signals to individual OLEDs as they can't share the bus directly.
Schematics
Bill of Materials
Device | Usage | Price |
---|---|---|
Raspberry Pi Pico 2 | Microcontroller | 40 RON x 2 |
TCA9548A I2C Mux | OLED Routing | 20 RON |
OLED 128x64 Displays ×9 | Visual display | 19 RON ×9 |
RGB LED ×2 | Player/Dealer Indicators | 2 RON ×2 |
Push Buttons ×3 | Game Inputs | 2 RON ×3 |
Breadboard | Connectivity | 10 RON |
Jumpers | Connectivity | 8 RON |
TOTAL: ~300 RON
Software
Library | Description | Usage |
---|---|---|
embassy-rp | RP2040 HAL | Async device and timer management |
embedded-hal-async | HAL Traits | I2C abstraction |
ssd1306 | OLED Driver | Display game cards/state |
heapless | Fixed capacity collections | Buffer text messages for OLEDs |
defmt + defmt-rtt | Logging Framework | Used for real-time debug output over RTT, ideal for embedded logging |
panic-probe | Panic Handler | Provides panic messages compatible with defmt |