Embedded systems · Independent
Two-player STM32 Pong
A playable two-player game built around register-level peripheral drivers, interrupt-driven input, and a buffered LED display.
- C
- STM32F411
- ADC
- DMA
- I2C
Goal
Build a two-player Pong game on an STM32F411 using two analog joysticks and two 8×8 LED matrices. I used the project to bring input, graphics, game logic, and audio together in one embedded application.
My Role
I independently wrote the register-level C APIs for ADC, I2C, DMA, and PWM audio, along with the ball physics and game-state logic. I worked directly with peripheral registers rather than using HAL drivers.
How It Works
Separate input from display transfers
ADC conversion-complete interrupts capture two analog input channels. A 32-byte shadow buffer stores the 16×8 playfield, and two 17-byte DMA transfers send the display payloads over I2C configured at 100 kHz.
Make game behavior explicit
A four-state machine handles idle, countdown, gameplay, and scoring through function-pointer dispatch. Display updates and ball movement use separate schedules.
Increase difficulty predictably
The ball starts with a 200 ms step interval. Every five paddle hits, I reduce that interval by 15%; the first change is from 200 ms to 170 ms.
Testing & Debugging
I demonstrated a playable two-player game on the hardware, with joystick input, collisions, scoring, display updates, and audio feedback working together. Moving display transfers to DMA replaced CPU-driven byte writes, though I haven’t measured the frame-rate difference.
Result
A working embedded game that connects custom drivers with application-level state and timing logic.