A Simon Says-style memory game built for embedded systems, featuring colorful NeoPixel LEDs, an OLED display, and multiple difficulty levels. Available in both Arduino C++ and MicroPython (Raspberry Pi Pico) implementations.
- Overview
- Features
- Hardware Requirements
- Software Requirements
- Installation
- Gameplay
- Controls
- Difficulty Levels
- Project Structure
- Code Implementation
- Troubleshooting
- Credits
Hassan's Hackpad is an interactive memory game where players must watch a sequence of colored LEDs and repeat it back correctly. The game progressively increases in difficulty, testing your memory and reaction time. With multiple difficulty levels, score tracking, statistics, and practice mode, it offers a complete gaming experience on embedded hardware.
- 4 Difficulty Levels: Easy, Normal, Hard, and Extreme
- Practice Mode: Learn without time pressure (sequence shows 3 times)
- Score Tracking: Top 5 scores saved per difficulty level
- Statistics: Track games played, average scores, and performance by difficulty
- Visual Feedback: Rainbow animations, LED celebrations, and OLED display
- Pause Functionality: Pause and resume games at any time
- Quick Restart: Restart games immediately after game over
- Persistent Storage: Scores and statistics saved to flash memory
- Dual Implementation: Available in both Arduino C++ and MicroPython
- Microcontroller:
- Seeed Studio XIAO RP2040 (for C++ or python)
- Display: 0.91" OLED Display (128x32 pixels, I2C)
- LEDs: 4x NeoPixel LEDs (SK6812 MINI)
- Buttons: 4x MX Cherry push buttons
- Resistors: Pull-up resistors for SDA and SCL
- Power: Supply by 3 AA battery holder (BC3AAAPC)
- LEDs: GPIO 3
- Buttons:
- Button 1 (Red): GPIO 26
- Button 2 (Blue): GPIO 27
- Button 3 (Green): GPIO 28
- Button 4 (Yellow): GPIO 29
- OLED I2C:
- SDA: GPIO 7
- SCL: GPIO 6
- Address: 0x3C
The project includes a custom PCB design with all components integrated:
The complete schematic shows all component connections and power distribution.
The custom PCB integrates all components in a compact form factor suitable for handheld gaming.
Custom 3D-printable case designs are available:
- Arduino IDE
- Libraries:
Adafruit_SSD1306(OLED display)Adafruit_GFX(Graphics library)Adafruit_NeoPixel(LED control)ArduinoJson(JSON parsing)SPIFFS(File system - built-in for ESP32)
- MicroPython firmware for XIAO RP2040
- Libraries (install via
mipor copy to device):adafruit_ssd1306adafruit_framebufneopixel(built-in)
-
Install Arduino IDE and add the XIAO RP2040 board support:
- Go to File > Preferences > Additional Board Manager URLsr URLs
- Add:
https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json - Go to Tools > Board > Boards Manageranager
- Search for "Raspberry Pi Pico/RP2040" and install
-
Install Required Libraries:
- Go to Sketch > Include Library > Manage Librariesraries
- Install:
- Adafruit SSD1306
- Adafruit GFX Library
- Adafruit NeoPixel
- ArduinoJson
-
Upload Code:
- Open
Code/code.cppin Arduino IDE - Select board: Seeed XIAO RP2040
- Select port
- Click Upload
- Open
-
Initialize SPIFFS (for score storage):
- Use a SPIFFS uploader tool or format SPIFFS partition
- Scores will be saved automatically on first run
-
Flash MicroPython:
- Download MicroPython firmware from micropython.org
- Hold BOOTSEL button on XIAO RP2040
- Connect to computer via USB
- Copy
.uf2file to mounted drive
-
Install Libraries:
# Connect via serial/REPL and run: import mip mip.install("adafruit-ssd1306")
-
Upload Code:
- Copy
Code/code.pyto the XIAO RP2040 asmain.py - The device will run automatically on boot
- Copy
- Watch the Sequence: LEDs will light up in a specific order
- Repeat the Sequence: Press the buttons in the same order
- Advance Levels: Each level adds more colors to remember
- Beat the Timer: Complete the sequence before time runs out (in normal mode)
- Track Progress: Your scores are automatically saved
- Sequence shown once
- Timer decreases each level
- Scores tracked and saved
- Personal best tracking
- Sequence shown 3 times
- No timer pressure
- Perfect for learning
- Scores not saved
| Button | Function | Color |
|---|---|---|
| B1 | Up / Red | 🔴 Red |
| B2 | Down / Blue | 🔵 Blue |
| B3 | Select / Green | 🟢 Green |
| B4 | Back / Yellow / Pause | 🟡 Yellow |
- B1 (UP): Navigate menu up
- B2 (DOWN): Navigate menu down
- B3 (SELECT): Select menu item / Confirm
- B4 (BACK): Go back / Cancel
- B1-B4: Press corresponding colored button
- B4 (Hold): Pause game
- B3 (in pause): Resume game
- B4 (in pause): Quit to menu
- B3: Quick restart (within 3 seconds)
- B4: Return to menu
- Any button: Continue after 3 seconds
| Difficulty | Start Time | Time Decrease | Sequence Increment | Description |
|---|---|---|---|---|
| Easy | 6.0s | 0.15s/level | +1 color | Gentle learning curve |
| Normal | 5.0s | 0.3s/level | +1 color | Balanced challenge |
| Hard | 4.0s | 0.45s/level | +2 colors | Fast-paced action |
| Extreme | 3.0s | 0.6s/level | +3 colors | Maximum difficulty |
- Start Time: Initial time limit per level
- Time Decrease: How much time reduces each level (minimum 1.0s)
- Sequence Increment: How many new colors added per level
Hassan-Hackpad/
├── Code/
│ ├── code.cpp # Arduino C++ implementation
│ └── code.py # MicroPython implementation
├── Images/
│ ├── Schematic.png
│ ├── PCB 3D Top View.png
│ ├── PCB 3D Bottom View.png
│ ├── PCB Routing.png
│ ├── 3D Case Top.png
│ └── 3D Case Bottom.png
├── HackpadPCB/ # KiCad PCB design files
├── 3D/ # 3D component models
├── 3D case/ # 3D printable case files
└── Footprint/ # KiCad footprints and symbols
s and symbols
- Top 5 scores saved per difficulty
- JSON-based storage (SPIFFS for C++, file system for Python)
- Automatic sorting and ranking
- Personal best tracking
- Total games played
- Average scores (overall and per difficulty)
- Games played per difficulty
- Persistent storage across power cycles
- Rainbow Cycle: Smooth color transitions
- Success Celebration: Multi-color flash on level completion
- Visual Feedback: LEDs light up when buttons pressed
- Error Indication: Red flash on wrong button press
- 3-line text display on 128x32 OLED
- Menu navigation with visual feedback
- Real-time timer display
- Game over screens with statistics
- Hardware Configuration: Pin definitions and constants
- LED Functions: Control and animation
- Display Functions: OLED text rendering
- File I/O: SPIFFS-based score/stats storage
- Button Input: Debounced button reading
- UI Functions: Menus, screens, navigation
- Game Logic: Main game loop and mechanics
- Similar structure to C++ version
- Uses MicroPython libraries
- File-based storage instead of SPIFFS
- Pythonic implementation with dictionaries
- Check wiring to GPIO 3
- Verify power supply (NeoPixels need 5V)
- Check brightness setting in code
- Ensure correct data pin connection
- Verify I2C connections (SDA/SCL)
- Check I2C address (should be 0x3C)
- Ensure proper power supply
- Try different I2C pins if needed
- Check pull-up resistors (or internal pull-ups)
- Verify button wiring (pressed = LOW)
- Check debounce timing
- Test buttons individually
- C++: Ensure SPIFFS is initialized
- Python: Check file system permissions
- Verify JSON file format
- Check available flash memory
- Check for infinite loops in button handling
- Verify timer calculations
- Ensure proper delay() usage
- Check memory usage
- C++: Optimized for XIAO RP2040 (dual-core, 264KB RAM)
- Python: Uses efficient MicroPython implementation
- LED Updates: Batched updates to reduce flicker
- Display: Frame buffer for smooth rendering
This project is created by Hassan Mohamed. All rights reserved.
Developer: Hassan Mohamed
Project: Hassan's Hackpad - Memory Game
Hardware: Custom PCB design with Seeed Studio XIAO RP2040 / Raspberry Pi Pico
Libraries Used:
- Adafruit SSD1306 (OLED display)
- Adafruit GFX (Graphics)
- Adafruit NeoPixel (LED control)
- ArduinoJson (JSON parsing)
For issues, questions, or contributions:
- Check the troubleshooting section
- Review code comments
- Verify hardware connections
- Test with practice mode first
Enjoy playing Hassan's Hackpad! 🎮✨