Pico Minesweeper
The classic minesweeper game, ported to the Raspberry Pi Pico.
Author: Iuga Darius-Gabriel-Ioan
GitHub Project Link: https://github.com/UPB-PMRust-Students/proiect-DariusIuga
Description
This project implements an interactive Minesweeper game, controlled via a joystick (for navigation) and buttons (for placing flags/menu interaction), with output displayed on an LCD screen. The player sets the grid size and the number of mines through a graphical menu, adjusting values with the joystick. At the end of the game, sounds (via a passive buzzer) signal victory or explosion. If a mine explodes, a vibration motor will be activated.
Game states can be saved locally (on a microSD card). Saved maps can be visualized on a dedicated website, served by an HTTP server hosted on the Pico W.
Motivation
I chose to implement Minesweeper over other games because it seemed to offer an appropriate level of difficulty (harder than Tic-Tac-Toe or Space Invaders, but easier than Chess). By using the chosen peripherals and incorporating save/load functionality, along with the ability to view saved games via a web interface, I hope to provide an engaging gameplay loop for the player.
Architecture
Log
TODO
Week 5 - 11 May
Week 12 - 18 May
Week 19 - 25 May
Hardware
The project utilizes a Raspberry Pi Pico W microcontroller as the central processing unit. User interaction is handled by a biaxial joystick for grid navigation and menu control, along with several push buttons for actions like placing flags, restarting, accessing the menu, and potentially other features. Visual feedback is provided through a 2.8" SPI LCD display (ILI9341 controller). Audio and haptic feedback are implemented using a passive buzzer and a vibration motor. Game state persistence and map storage are managed using a microSD card connected via SPI. The Pico W's wireless capability is used to host a local HTTP server, allowing saved maps to be viewed remotely. A second Pico is used as a debug probe (Picoprobe).
Schematics
TODO
Place your KiCAD schematics here.
Bill of Materials
Device | Usage | Price |
---|---|---|
Breadboard HQ (830 Puncte) | Breadboard | 10 RON |
Set de fire Rigide pentru Breadboard | Jumper cables | 12.5 RON |
Modul LCD SPI de 2.8" cu Touchscreen - Controller ILI9341 și XPT2046 (240x320 px) | The LCD display | 70 RON |
Motor cu vibratii A1027 | The Vibration motor | 10 RON |
Buzzer Pasiv de 3.3V sau 3V | Passive buzzer | 1 RON |
Modul Joystick Biaxial Negru cu 5 pini | Joystick with button | 5.35 RON |
Card MicroSD Original de 16 GB cu NOOBs Compatibil cu Raspberry Pi 4 Model B Varianta Bulk | SD card + adapter | 40 RON |
Raspberry Pi Pico 2W (2 pieces) | 2 microcontrollers, one used as a debug interface | 80 RON |
Header de pini (40p) (4 pieces) | Header pins | 4 RON |
Buton 6x6x6 (10 pieces) | Buttons | 3.6 RON |
Cablu Albastru Micro USB 50 cm | Micro USB cable | 3 RON |
Software
Library | Description | Usage |
---|---|---|
embassy-executor | async/await executor designed for embedded usage | Runs and manages all asynchronous tasks (input handling, display updates, networking, game logic). |
embassy-rp | Embassy Hardware Abstraction Layer (HAL) for the Raspberry Pi RP2040 microcontroller | Interfacing with Pico W hardware: GPIO (buttons, joystick, buzzer, motor), SPI (LCD, SD card). |
embassy-time | Instant and Duration for embedded no-std systems, with async timer support | Implementing delays, timeouts, debouncing inputs, potentially game timers. |
embassy-net | Async TCP/IP network stack for embedded systems | Providing the underlying networking capabilities for the HTTP server. |
cyw43 | Rust driver for the CYW43439 WiFi chip, used in the Raspberry Pi Pico W. | Enabling WiFi connectivity via the Pico W's onboard wireless chip. |
picoserve | An async no_std HTTP server suitable for bare-metal environments | Implementing the HTTP server to serve saved game maps over WiFi. |
defmt | A highly efficient logging framework that targets resource-constrained devices, like microcontrollers | Debug logging during development via the debug probe. |
mipidsi | MIPI Display Command Set compatible generic driver usage | Low-level driver for communicating with the ILI9341 LCD controller over SPI. |
embedded_graphics | Embedded graphics library for small hardware displays | Drawing the game grid, menus, text, and other UI elements on the LCD. |
embedded-sdmmc | A basic SD/MMC driver for Embedded Rust. | Reading from and writing to the microSD card for game save/load functionality. |
oorandom | A tiny, robust PRNG implementation. | Generating random numbers for placing mines on the game board. |