Skip to main content
Version: FILS English

Poker Game

A poker game against an AI using rust and the Raspberry Pi Pico 2

info

Author: Ciortan Rares-Sebastian
GitHub Project Link: https://github.com/UPB-PMRust-Students/project-troly69

Description

Pocket Poker is a single-player Texas Hold'em-style poker game that runs entirely on a Raspberry Pi Pico 2W, using a 1.8" SPI TFT LCD for the displays and push buttons for input. The game allows the player to go head-to-head against a simple AI dealer, simulating betting rounds, card dealing, and hand evaluation. All logic and graphics are written in Rust, demonstrating how embedded systems can be used for interactive, game-like applications without requiring internet or external screens.

Motivation

I wanted to create something more interactive and fun than traditional embedded projects. Poker is a great balance of logic, randomness, and user interface work. This project is a chance to explore Rust for embedded systems, work with SPI-based LCDs, and implement game logic on limited hardware.

Architecture

Architecture Diagram

Raspberry Pi Pico 2W: Acts as the main controller. Runs the game logic written in Rust. Communicates with the displays via SPI and handles button input through GPIO. -Connection: Communicates with the display via SPI and handles button input through GPIO.

Buttons: Used for player inputs (Check,Bet,Fold). -Connection: Each button is connected to a GPIO pin with pull-down resistors for clean signals. Displays: Used to show the table cards, your cards, balance of both players/game state. -Connection: Connected via SPI (MOSI and CLK), plus control pins (CS, DC, RST).

Log

Week 5-11 May

wip

Week 12-18 May

wip

Week 19-25 May

wip

Hardware

The hardware consists of a raspberry pi pico 2W microcontroller as the core unit, around 3 displays used for displaying the cards, balance etc. , buttons for checking, folding, betting.

Bill of materials

DeviceUsagePrice
Raspberry Pi Pico 2WThe microcontroller[40 RON]
Wireless Super Starter Kit with ESP8266 (Programmable with Arduino IDE)Kit[65 RON]
3X Modul LCD SPI de 1.8"(128x160)LCD Display[29 RON]
[Breadboard]Connectivityin kit
[Buttons] X3Game Inputsin kit
[Jumpers]Connectivityin kit
TOTAL: 200 RON

Software

Library / ToolDescriptionUsage
rp-picoBoard support crate for Raspberry Pi Pico (W)Provides pin definitions, boot setup, and HAL integration
rp2040-halHardware Abstraction Layer for the RP2040Access to SPI, GPIO, timers, clocks, etc.
embedded-halEmbedded hardware abstraction traitsInterface between display/button drivers and hardware
st7735-lcdRust driver for ST7735 LCD over SPIUsed to draw graphics and text to the LCD screen
embedded-graphics2D graphics library for embedded displaysDraws text, shapes, cards, etc. on screen
cortex-mLow-level access to ARM Cortex-M processorsRequired for system boot and interrupts
cortex-m-rtRuntime support for Cortex-MEntry point and memory layout setup
panic-haltHalts the program on panicSimple panic handler for embedded
embedded-timeTime units and delays for embeddedUsed for timing animations or button debounce
probe-rs (optional)Flash and debug Rust code to microcontrollersUsed to upload code directly (or you can use elf2uf2)
  1. [Texas Hold'em rules] (https://casinos.lotoquebec.com/dam/jcr:c49e36e5-1e3d-4123-ae10-e7250d837140/Regles_Ultimate-Texas-Holdem_e.pdf)
  2. [embedded-graphics] (https://github.com/embedded-graphics/examples)
  3. [Rust on Raspberry Pi Pico Guide] (https://github.com/knurling-rs/app-template)