Minesweeper
Classic implementation of the minesweeper game where the goal is to reveal all the cells without hitting a mine.
Author: Dobrin David-Andrei
GitHub Project Link: https://github.com/UPB-PMRust-Students/proiect-ddavid03dda
Description
Classic implementation of the minesweeper game where the goal is to reveal all the cells without hitting a mine. Also several difficulty levels that increase the number of mines on the map. The player can see in a menu the battery status and select the difficulty before the game starts and then play until he loses or wins.
Motivation
It was a favorite game I used to play as a kid when the internet was down. I wanted to build a physical version I could keep around the house—complete with sounds and vibration—to give it a fresh, tactile feel.
Architecture
- Raspberry Pi Pico 2 W as central control unit, running the game logic in Rust.
- Vibration motor to signal when the player hits a mine (loss).
- Buzzer for sound effects—menu navigation, tile selection, win/loss alerts.
- ILI9341 LCD to display the menu, battery status, and game grid.
- Buttons for cursor movement, selection, and menu control.
Log #
Week 5 – 11 May
Week 12 – 18 May
Week 19 – 25 May
Hardware
-
Raspberry Pi Pico 2 W
- Purpose: Main controller.
- Function: Runs the Minesweeper game logic in Rust, reads button inputs, and drives the display, buzzer, and vibration motor.
-
Vibration Motor
- Purpose: Haptic feedback.
- Function: Vibrates briefly when the player uncovers a mine (loss).
-
Buzzer
- Purpose: Audio feedback.
- Function: Emits tones for menu navigation, tile reveals, and win/loss alerts.
-
ILI9341 LCD
- Purpose: Visual interface.
- Function: Displays the difficulty menu, battery status, game grid, and end-game messages.
-
Push-buttons (×5)
- Purpose: User controls.
- Function: Up, Down, Left, Right for cursor movement; Select for revealing tiles and confirming menu choices.
Hardware Overview
- The Raspberry Pi Pico 2 W orchestrates all inputs and outputs, executing the Minesweeper logic.
- Push-buttons let the player navigate menus and move the cursor across the minefield.
- The ILI9341 LCD renders the game grid, menus, and battery level in real time.
- The Buzzer provides immediate audio cues for safe tile reveals, mine hits, and victories.
- The Vibration Motor delivers a tactile buzz when a mine is uncovered, reinforcing the loss event.
Schematics
Bill of Materials
Device | Usage | Price |
---|---|---|
Raspberry Pi Pico 2 W | Main microcontroller | 80 RON |
Vibration motor module | Loss feedback vibration | 15 RON |
Colored wires male–male (40 × 10 cm) | Wiring between Pico and peripherals | 5 RON |
Colored wires male–female (40 × 15 cm) | Wiring sensor/buttons | 8 RON |
Colored wires female–female (40 × 15 cm) | Breadboard‐to‐module wiring | 7 RON |
Passive buzzer (3.3 V) | Sound effects | 1 RON |
NPN Transistor 2N2222 TO-92 | Driving buzzer/vibration motor | 0.17 RON |
Breadboard HQ (400 pts) | Prototyping | 4.50 RON |
Resistor 0.25 W 2.2 kΩ | Current limiting | 0.10 RON |
Diode 1N4007 | Flyback protection | 0.50 RON |
40-pin male header, 2.54 mm (×5) | GPIO breakout | 5 RON |
ILI9341 LCD (2.4″, SD slot) | Display | 67 RON |
Push-buttons × 5 | User input | 10 RON |
Software
Library | Description | Usage |
---|---|---|
rp2040-hal | Hardware Abstraction Layer for Raspberry Pi Pico | GPIO, PWM, ADC, timers |
embedded-hal | Common traits for embedded hardware access | Digital I/O, SPI bus, delay timers |
embedded-graphics | 2D graphics library for embedded displays | Rendering grid, menus, battery indicator |
ili9341 | ILI9341 TFT display driver | SPI communication with the LCD |
panic-halt | Minimal panic handler | Halts MCU on unrecoverable errors |
nb | Non-blocking I/O traits | Debouncing buttons, reading battery level |