Skip to main content
Version: ACS CC

BlackJack Machine

A singleplayer card game powered by a Raspberry Pi Pico 2 and Rust.

info

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:

  1. Startup: OLED instructs user to press START.
  2. Dealer draws 2 cards – LED blinks – game state updates.
  3. Player draws 2 cards – LED blinks – game state updates.
  4. Player phase: can HIT (get card) or STAND (end turn).
  5. If player busts: game ends.
  6. Else: dealer draws to at least 17.
  7. 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

diagram

Log

Week 5 – 11 May

TO DO

Week 12 – 18 May

TO DO

Week 19 – 25 May

TO DO

Hardware

  1. Raspberry Pi Pico 2 - RP2350A

    • Main microcontroller; handles game logic, I2C communication, and peripheral control.
  2. 2 Push Buttons (HIT & STAND)

    • User input; GPIO with pull-ups.
  3. 2 RGB LEDs

    • Visual indicators for player/dealer turn and result status.
  4. 9 OLED 0.96" Displays (128x64)

    • Display game content (cards and messages). All share the same I2C address.
  5. TCA9548A I2C Multiplexer

    • Routes signals to individual OLEDs as they can't share the bus directly.

Schematics

diagram

Bill of Materials

DeviceUsagePrice
Raspberry Pi Pico 2Microcontroller40 RON x 2
TCA9548A I2C MuxOLED Routing20 RON
OLED 128x64 Displays ×9Visual display19 RON ×9
RGB LED ×2Player/Dealer Indicators2 RON ×2
Push Buttons ×3Game Inputs2 RON ×3
BreadboardConnectivity10 RON
JumpersConnectivity8 RON

TOTAL: ~300 RON

Software

LibraryDescriptionUsage
embassy-rpRP2040 HALAsync device and timer management
embedded-hal-asyncHAL TraitsI2C abstraction
ssd1306OLED DriverDisplay game cards/state
heaplessFixed capacity collectionsBuffer text messages for OLEDs
defmt + defmt-rttLogging FrameworkUsed for real-time debug output over RTT, ideal for embedded logging
panic-probePanic HandlerProvides panic messages compatible with defmt
  1. BlackJack rules
  2. Raspberry Pi Pico Tutorial - SSD1306 I2C OLED DISPLAY
  3. Playing cards images
  4. Using I2C MUX with OLEDs