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

Pac-Man-on-an-ESP32-with-a-tiny-OLED-screen.png

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:

  1. ESP32 game projects
  2. OLED display projects
  3. Arduino gaming projects
  4. SSD1306 tutorials
  5. DIY handheld consoles
  6. 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:

  1. “best ESP32 OLED projects”
  2. “ESP32 SSD1306 game tutorial”
  3. “how to make a game with ESP32”
  4. “DIY Arduino game console”
  5. “ESP32 joystick game”

…this project is exactly for you.

Supplies

esp32.jpg
joystick.jpg
oled.jpg

Wiring

Pinout-and-wiring-diagram-of-the-ESP32-with-I2C-OLED-display-and-analog-joystick-module-for-programming-in-Arduino-or-MicroPython.png

# 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:

  1. OLED rendering engine
  2. Ghost AI pathfinding
  3. Collision detection
  4. Smooth player movement
  5. Pellet system
  6. Sound effects
  7. HUD system

GitHub source code:

https://github.com/webzf/esp32-oled-pac-man-game

How the Ghost AI Works

transferir.jpg

The ghosts automatically chase the player using a simple pathfinding system.

The algorithm:

  1. Detects available directions
  2. Avoids walls
  3. Calculates shortest distance to Pac-Man
  4. Selects the best path

This makes the gameplay feel surprisingly realistic for such a small OLED game.

Final Result

DIY Pacman Game on ESP32! 🕹️ #Shorts #ESP32
Pac-Man on a $5 Screen 😳 #esp32 #short

You now have a fully working:

  1. ESP32 OLED game
  2. DIY retro arcade console
  3. Portable Pac-Man style game
  4. SSD1306 gaming project

This project is great for:

  1. Learning ESP32 graphics
  2. Understanding joystick input
  3. Practicing game logic
  4. Building viral electronics content
  5. YouTube Shorts projects
  6. Arduino portfolio projects


Video and More Projects