ESP32 LED Matrix Pong Animation
View on GitHub
Since I began coding in 2020, I have frequently recreated Pong anytime I'm experimenting with a new language or visual interface. It has been a sort of litmus test to explore what's possible, like my own "Hello World" project. My goal for this project was to take advantage of the quick prototyping nature of the Arduino framework to explore the ESP32-HUB75-MatrixPanel-DMA library. In doing so, I was able to get my first sketch running on a HUB75 LED matrix with a smooth framerate and no artifacting. The result? A CPU-controlled Pong simulation in an eternal battle between two bots.
Overview
Coded purely in C++, two classes define Paddle and Ball objects. Each object includes instructions for how it is drawn on the matrix, custom movement and collision logic, and pseudo-random fluctuations to provide visual interest and unpredictability. The simple shapes of Pong easily allow the Adafruit GFX Graphics Library to do some visual heavy lifting, providing performance advantages over direct pixel manipulation. The Arduino setup function handles LED matrix initialization, and the loop controls frame updates on the matrix at a consistent 60 FPS.
Gameplay Demo