ESP32 OLED Pac-Man Game Using SSD1306 Display and Analog Joystick
by ztr0nics in Circuits > Microcontrollers
82 Views, 1 Favorites, 0 Comments
ESP32 OLED Pac-Man Game Using SSD1306 Display and Analog Joystick
Build a Retro OLED Arcade PacMan Game with ESP32
Want to make an ESP32 OLED game using an SSD1306 display and joystick module? In this project, I’ll show you how to build a smooth Pac-Man style game on ESP32 with animated sprites, ghost AI, sound effects and retro arcade gameplay.
This is a fun DIY electronics project for anyone interested in:
- ESP32 game projects
- OLED display projects
- Arduino gaming projects
- SSD1306 tutorials
- DIY handheld consoles
- Microcontroller entertainment systems
The project uses inexpensive components and is perfect for beginners and intermediate makers.
Why This ESP32 OLED Game Project Is Cool
Unlike simple OLED demos, this project includes:
✅ Smooth movement physics
✅ Animated Pac-Man sprites
✅ Intelligent ghost chasing AI
✅ Score and lives system
✅ Analog joystick controls
✅ Retro sound effects
✅ Real-time gameplay on ESP32
If you searched for:
- “best ESP32 OLED projects”
- “ESP32 SSD1306 game tutorial”
- “how to make a game with ESP32”
- “DIY Arduino game console”
- “ESP32 joystick game”
…this project is exactly for you.
Supplies
Parts Used
ESP32 Development Board
SSD1306 OLED Display
Analog Joystick Module
Passive Buzzer
Jumper Wires
Wiring
# Step 1: Wiring the OLED Display
Connect the SSD1306 OLED display to the ESP32 using I2C.
| OLED | ESP32 |
|---|---|
| VCC | 3.3V |
| GND | GND |
| SDA | GPIO 21 |
| SCL | GPIO 22 |
The SSD1306 is one of the best displays for ESP32 projects because it is cheap, low-power and easy to use.
---
# Step 2: Connecting the Joystick
The joystick controls Pac-Man movement.
| Joystick | ESP32 |
|---|---|
| VRX | GPIO 35 |
| VRY | GPIO 34 |
| SW | GPIO 27 |
| VCC | 3.3V |
| GND | GND |
This analog joystick module is commonly used in ESP32 gaming projects and DIY handheld consoles.
---
# Step 3: Connecting the Buzzer
The passive buzzer creates retro arcade sound effects.
| Buzzer | ESP32 |
|---|---|
| + | GPIO 13 |
| - | GND |
Upload the Code
Upload the Pac-Man game code to your ESP32 board.
Main features inside the code:
- OLED rendering engine
- Ghost AI pathfinding
- Collision detection
- Smooth player movement
- Pellet system
- Sound effects
- HUD system
GitHub source code:
How the Ghost AI Works
The ghosts automatically chase the player using a simple pathfinding system.
The algorithm:
- Detects available directions
- Avoids walls
- Calculates shortest distance to Pac-Man
- Selects the best path
This makes the gameplay feel surprisingly realistic for such a small OLED game.
Final Result
You now have a fully working:
- ESP32 OLED game
- DIY retro arcade console
- Portable Pac-Man style game
- SSD1306 gaming project
This project is great for:
- Learning ESP32 graphics
- Understanding joystick input
- Practicing game logic
- Building viral electronics content
- YouTube Shorts projects
- Arduino portfolio projects
Video and More Projects
YouTube
https://www.youtube.com/@ztr0n1cs
https://www.pinterest.com/ztronics03/
Instructables Profile
https://www.instructables.com/member/ztr0nics/