PicoSudoku
A microcontroller-powered Sudoku game, designed for the Raspberry Pi Pico 2
Author: Ionescu Mihai-Cosmin
GitHub Project Link: https://github.com/UPB-PMRust-Students/proiect-COSSS02
Description
This project aims to provide a simple and engaging way to play the classic logic game Sudoku, featuring three difficulty levels. The game grid is displayed on an LCD screen connected to a Raspberry Pi Pico 2 microcontroller. The user can interact with the game using intuitive hardware controls: a joystick for navigating between cells and a keypad for number input. The system includes input validation and displays a warning inside the grid for invalid moves. At the end of the game, the time needed to beat the puzzle is displayed.
Motivation
This project combines my passion for logic puzzles with the challenge of creating a clean, self-contained implementation. Sudoku's structured nature makes it an ideal candidate for an embedded environment project.
Architecture
Log
Week 5 - 11 May
- Environment setup for picotool flashing
- USB logging for log messages instead of using a debugger
- Keypad initialization
- Keypad polling for input reading
- Joystick initialization
- Joystick polling for determining the direction when it's moved
- Multiplexed Input between the Keypad and the Joystick
Week 12 - 18 May
- SPI bus initialisation
- Display initialisation
- Display comatibility with embedded-grpahics library
Week 19 - 26 May
- Sudoku board generation
- Sudoku control using input peripherals
- Sudoku grid drawing
- Startup screen with difficulty selection
- Warnings inside grid for invalid moves
- Game over ending screen
- Timer for how long it takes to beat the level
Hardware
The project uses four main hardware components:
- Raspberry Pi Pico 2 as the microcontroller
- 2.8-inch ST7789 SPI TFT LCD to display the Sudoku grid
- 3x4 matrix keypad for number input
- dual-axis XY joystick for navigating between cells.
Schematic
Bill of Materials
Device | Usage | Price |
---|---|---|
Raspberry Pi Pico 2 | The microcontroller | 42 RON |
2.8 Inch ST7789 LCD | The display | 38 RON |
3X4 Matrix Switch Keypad | The keypad | 12 RON |
Dual-axis XY Joystick Module | The joystick | 8 RON |
Software
Library | Description | Usage |
---|---|---|
embassy-rp | Raspberry Pi Pico HAL | GPIO, SPI, ADC setup |
embassy-sync | Synchronization primitives | Mutex for SPI bus |
embassy-time | Time handling mechanisms | Measure Game Runtime |
embassy_usb_logger | USB implementation of the log crate | Debugging & logging player actions |
mipidsi | Crate for generic display drivers | Display driver for ST7789 |
embedded-graphics | 2D graphics library | Drawing primitives to the display |
picorand | Fast random number generator library | Generating the Sudoku game board |
micromath | Embedded-friendly math library | Common arithmetic operations |