Overview
A hardware version of Whack-a-Mole running on a NUCLEO-F446ZE board (STM32F446, Arm Cortex-M4). Moles appear on an OLED screen and the player hits them using a 4x3 matrix keypad. Scores are kept between power cycles.
The problem
Embedded programming means working directly with timing, memory and peripherals. This project was a way to practise all of them in one small, testable system.
Context and motivation
ECE342, embedded systems. A game gives instant feedback when something is wrong, which makes it a good teacher.
My role
To write.
Approach
The code is split by responsibility: game logic, user interface, flash storage and fonts, each in its own module.
Technical architecture
A keypad is scanned for input, an SSD1306 OLED is driven over I2C, and a high score is written to flash memory (sector 7). Timing uses the HAL millisecond tick, and the game loop is non-blocking so input never stalls the display.
Implementation
Two details worth showing: flash must be erased before it is written, and the stored score is guarded by a magic-number check so a blank or corrupted sector is not mistaken for a real score.
Trade-offs and decisions
| Option | Trade-off | Chosen |
|---|---|---|
| Non-blocking timing with SysTick | Slightly more state to manage | Yes |
| Blocking delays | Simpler, but freezes input and display | No |
Results and impact
A working game with persistent high scores. Add anything measurable you can stand behind.
Lessons learned
Regenerating code from the board configuration tool overwrote custom code that sat outside the protected USER CODE blocks. Keep your code inside them.
What's next
To write.
Links and resources
Repository link, if public.