Chapter 5 Pong Game
We have experienced single-player game snake before. Now, let’s use ESP32 board to play classic two-player pong game. You will experience both 2D and 3D version.
Project 5.1 Pong Game
First, let’s experience the 2D version game.
Component List
ESP32-WROVER x1
|
GPIO Extension Board x1
|
Breadboard x1
|
|
Rotary potentiometer x2
|
Jumper M/M x6
|
Circuit
Use A0, A3 ports on ESP32 board to detect the voltage of rotary potentiometers.
Schematic diagram |
|
Hardware connection |
|
Sketch
Sketch Pong_Game
Use Processing to open Pong_Game and click Run. If the connection succeeds, the follow will be shown:
Now you can try to turn the potentiometer to control the movement of paddle without ball. Press space bar to start the game:
Use potentiometer to control the movement of paddle to block the ball back. The game rules are the same as classic pong game:
The game will be over when one side reachs three points. Pressing the space bar can restart the game:
Additionally, you can restart the game by pressing the space bar at any time.
Project 5.2 Pong Game 3D
Now, let’s experience the 3D version game.
Component list
The same as last section.
Circuit
The same as last section.
Sketch
Sketch Pong_Game_3D
Use Processing to open Pong_Game_3D.pde and click Run. If the connection succeeds, the follow will be shown:
Now you can try to turn the potentiometer to control the movement of paddle without ball. Press space bar to start the game:
Use potentiometer to control the movement of paddle to block the ball back. The game rules are the same as classic pong game:
The rest operation is the same as the 2D version.






