Skip to main content
Version: ACS CC

PicoSudoku

A microcontroller-powered Sudoku game, designed for the Raspberry Pi Pico 2

info

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.

Video Demonstration

Sudoku

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​

Diagram

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.

Hardware

Schematic​

Schematic

Bill of Materials​

DeviceUsagePrice
Raspberry Pi Pico 2The microcontroller42 RON
2.8 Inch ST7789 LCDThe display38 RON
3X4 Matrix Switch KeypadThe keypad12 RON
Dual-axis XY Joystick ModuleThe joystick8 RON

Software​

LibraryDescriptionUsage
embassy-rpRaspberry Pi Pico HALGPIO, SPI, ADC setup
embassy-syncSynchronization primitivesMutex for SPI bus
embassy-timeTime handling mechanismsMeasure Game Runtime
embassy_usb_loggerUSB implementation of the log crateDebugging & logging player actions
mipidsiCrate for generic display driversDisplay driver for ST7789
embedded-graphics2D graphics libraryDrawing primitives to the display
picorandFast random number generator libraryGenerating the Sudoku game board
micromathEmbedded-friendly math libraryCommon arithmetic operations
  1. Creating a Raspberry Pi Pico ST7789 based coloured text display
  2. Pico Sudoku Puzzle Generator
  3. Driver for reading from standard 3X4 keypads