Skip to main content
Version: ACS CC

Pico Minesweeper

The classic minesweeper game, ported to the Raspberry Pi Pico.

info

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

drawio_diagram

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

DeviceUsagePrice
Breadboard HQ (830 Puncte)Breadboard10 RON
Set de fire Rigide pentru BreadboardJumper cables12.5 RON
Modul LCD SPI de 2.8" cu Touchscreen - Controller ILI9341 și XPT2046 (240x320 px)The LCD display70 RON
Motor cu vibratii A1027The Vibration motor10 RON
Buzzer Pasiv de 3.3V sau 3VPassive buzzer1 RON
Modul Joystick Biaxial Negru cu 5 piniJoystick with button5.35 RON
Card MicroSD Original de 16 GB cu NOOBs Compatibil cu Raspberry Pi 4 Model B Varianta BulkSD card + adapter40 RON
Raspberry Pi Pico 2W (2 pieces)2 microcontrollers, one used as a debug interface80 RON
Header de pini (40p) (4 pieces)Header pins4 RON
Buton 6x6x6 (10 pieces)Buttons3.6 RON
Cablu Albastru Micro USB 50 cmMicro USB cable3 RON

Software

LibraryDescriptionUsage
embassy-executorasync/await executor designed for embedded usageRuns and manages all asynchronous tasks (input handling, display updates, networking, game logic).
embassy-rpEmbassy Hardware Abstraction Layer (HAL) for the Raspberry Pi RP2040 microcontrollerInterfacing with Pico W hardware: GPIO (buttons, joystick, buzzer, motor), SPI (LCD, SD card).
embassy-timeInstant and Duration for embedded no-std systems, with async timer supportImplementing delays, timeouts, debouncing inputs, potentially game timers.
embassy-netAsync TCP/IP network stack for embedded systemsProviding the underlying networking capabilities for the HTTP server.
cyw43Rust driver for the CYW43439 WiFi chip, used in the Raspberry Pi Pico W.Enabling WiFi connectivity via the Pico W's onboard wireless chip.
picoserveAn async no_std HTTP server suitable for bare-metal environmentsImplementing the HTTP server to serve saved game maps over WiFi.
defmtA highly efficient logging framework that targets resource-constrained devices, like microcontrollersDebug logging during development via the debug probe.
mipidsiMIPI Display Command Set compatible generic driver usageLow-level driver for communicating with the ILI9341 LCD controller over SPI.
embedded_graphicsEmbedded graphics library for small hardware displaysDrawing the game grid, menus, text, and other UI elements on the LCD.
embedded-sdmmcA basic SD/MMC driver for Embedded Rust.Reading from and writing to the microSD card for game save/load functionality.
oorandomA tiny, robust PRNG implementation.Generating random numbers for placing mines on the game board.
  1. embedded_graphics - GUI library
  2. picoserve - HTTP library, built on top of embassy-net
  3. embedded_sdmmc - SD card library
  4. Embassy book