Skip to main content
Version: ACS CC

Light Pattern Memory Game

A light pattern recognition memory game powered by a Raspberry Pi Pico and Rust.

info

Author: Bogdan Ana-Maria-Iulia
GitHub Project Link: https://github.com/UPB-PMRust-Students/proiect-AnaBogdan

Description

A fully interactive memory game built on a Raspberry Pi Pico - RP2040, using the Rust programming language and Embassy async framework, based on recognizing and reproducing light patterns. The player must memorize a sequence of LEDs flashing in a 4x4 grid and reproduce it using capacitive touch sensors. The project features multiple game modes, a scoring system, timeout-based timer, high score storage in flash memory, and audio feedback. In multiplayer mode, two players compete to replicate sequences set by each other. Sequences can be random or predefined, and feedback is also given through varied sounds. At the end of each round, players' scores are compared and displayed.

Features:

  • 4x4 WS2812 RGB LED matrix for displaying light sequences.
  • Capacitive touch sensor (TTP229) for player input.
  • 240x240 ST7735 OLED Display for visual game status, scores, and instructions.
  • Audio feedback for correct/incorrect actions and UI sounds.
  • Multiplayer mode with random or user-defined sequences.
  • High score saving to flash memory.
  • Timeout-based turn system to increase challenge.

Motivation

This project was inspired by a memory game I played during a Neurolympics online assessment. I wanted to recreate the experience in hardware using Rust and the RP2040, turning a digital challenge into a hands-on embedded system that combines pattern recognition, real-time input, and visual/audio feedback.

Architecture

The Raspberry Pi Pico - RP2040 acts as the central unit, managing peripherals and orchestrating the game flow.

  • Capacitive Touch Module (GPIO/I2C): detects player input.
  • WS2812 LED Matrix (SPI): displays animated light patterns.
  • OLED Display ST7735 (SPI): shows current mode, instructions, score, and end results.
  • Audio Buzzer (PWM/GPIO): emits feedback tones based on actions.
  • Internal Flash: stores the highest score between sessions.

Game Flow Summary:

  1. Startup: OLED shows welcome message and instructions.
  2. Pattern Display: A sequence of LEDs light up in the 4x4 grid.
  3. Player Turn: User reproduces the sequence via touch sensors.
  4. Feedback: Correct/incorrect tones and visual confirmation.
  5. Scoring: Points are awarded per round; failure resets current round.
  6. Multiplayer (optional): Each player sets a sequence for the other to repeat.
  7. Game End: Scores are displayed; high score is updated if beaten.

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 - RP2040
  • Main microcontroller. Manages all peripheral communication, handles game logic, input processing, and feedback signals.
  1. 4x4 WS2812 RGB LED Matrix
  • Displays animated light patterns. Controlled via SPI or bit-banged protocol depending on implementation.
  1. TTP229 Capacitive Touch Sensor Module
  • Used for detecting user input. Offers up to 16 touch-sensitive buttons mapped to the LED matrix grid.
  1. ST7735 OLED Display (240x240)
  • Shows game status, round instructions, score updates, and high score.
  1. Audio Buzzer (Piezo)
  • Provides auditory feedback (correct/incorrect sounds, game tones, and timer alerts). Controlled via PWM.
  1. Breadboard and Jumper Wires
  • For prototyping, connecting all components in a modular and easily adjustable layout.
  1. Power Supply (USB / 5V adapter)
  • Powers the Raspberry Pi Pico and peripherals safely and consistently.

Schematics

TO DO

Bill of Materials

DeviceUsagePrice
Raspberry Pi PicoMicrocontroller30 RON x 2
4x4 LED Matrix WS2812Game Outputs20 RON
ST7735 OLED 240x240 DisplayVisual display33 RON
TP229 Capacitive Touch Sensor ModulePlayer Input9 RON
BreadboardConnectivity10 RON x2
Breadboard, Jumpers, Power supply etcConnectivity60 RON

TOTAL: ~200 RON

Software

LibraryDescriptionUsage
embassy-rpRP2040 HALAsync device and timer management
embedded-hal-asyncHAL TraitsI2C abstraction
ttp229Capacitive Sensor DriverUsed for the game input
st7735OLED DriverDisplay game mode and rules
ws2812_spiLED Matrix DriverDisplay game mode and rules
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. Game inspiration - Neurolympics
  2. Using TTP229 Capacitive Keypad with Raspberry Pi