ESP32 OLED Flappy Bird Game

Wiring Schematic

View full-size circuit ↗
LT

YOUR PROJECT LEARNING PATH

Build it with confidence.

Progress saves on this device
01

Project overview

Know what you’re building before you start wiring.

Build a Flappy Bird-style game using an ESP32 development board and a 128×64 SSD1306 OLED display. Touch input lets you flap the bird, avoid moving pipes, and chase higher scores.

The game includes collision detection, an animated bird, progressively faster pipes, a best-score display, a Game Over screen, and touch-to-restart controls. It runs locally without Wi-Fi or internet access.

Before you power up

Disconnect USB power before wiring. Verify OLED voltage and connect the ESP32, display, and touch sensor to common ground.

PROJECT ROADMAP3 project stages
✓
Prepare your kitConfirm the components and tools
⌁
Assemble the circuitFollow the build steps in order
⌘
Upload and testCheck the output and resolve issues
Start the build
02

Components required

Gather these parts before you begin.

ESP32 Development BoardRuns game logic, reads touch input, and updates OLED graphics.× 1
SSD1306 OLED Display128×64 I2C display showing the bird, pipes, current score, and best score.× 1
HW-139 Touch SensorProvides digital touch input for starting, flapping, and restarting gameplay.× 1
BreadboardHolds components and provides convenient connections during circuit assembly.× 1
Connecting WiresConnect OLED power, I2C signals, touch output, and common ground.× 10
USB CablePowers the ESP32 and uploads firmware from the computer.× 1
03

Build the project

Work through one focused step at a time. You can revisit any step whenever you need.

STEP 010 / 5 complete
BUILD STAGE 0120% of guide

Prepare the ESP32 and OLED Display

Disconnect USB power and place the ESP32, OLED display, and HW-139 touch sensor on a stable surface. Identify each module's power, ground, and signal pins before starting the wiring process.

The README specifies a 128×64 SSD1306 I2C display at address 0x3C. The supplied diagram says SH1106, so verify your actual display controller before wiring.

1 of 5
04

Software & tools

Install these before uploading the firmware.

Arduino IDEEdits, compiles, and uploads the game firmware to the ESP32 board.
ESP32 Board PackageAdds ESP32 Dev Module support and build configuration to Arduino IDE.
Adafruit GFX LibraryProvides drawing primitives and text functions used by the game graphics.
Adafruit SSD1306 LibraryInitializes and updates compatible SSD1306 OLED displays over I2C.
Wire LibraryProvides I2C communication between the ESP32 and OLED display.
Serial MonitorCan show OLED initialization errors when configured at 115200 baud.
05

Expected output

Compare your build with the result described here.

FINAL CHECKPOINT

After upload, the OLED shows the FLAPPY BIRD start screen, including the bird graphic and touch prompt. Touching the sensor begins gameplay, with the current score and best score shown above the play area.

The bird falls under gravity and rises when touched, while pipes move from right to left. Collisions with pipes, the ceiling, or ground trigger Game Over; touching again restarts the game, and the best score lasts only until reboot.

06

Troubleshooting & fixes

Choose the issue that best matches what you’re seeing.

01OLED remains blank or graphics appear corrupted
Try these checks

Check OLED 3.3V, GND, SDA on GPIO 21, and SCL on GPIO 22. Confirm the module uses an SSD1306 controller at address 0x3C and inspect jumper wires for loose connections.

02Touch sensor does not trigger jumps
Try these checks

Check HW-139 VCC, GND, and DO connections. Verify the output reaches GPIO 4 and becomes HIGH when touched; if the module uses active-LOW output, change the touch comparison in the sketch.

03Expected buzzer sounds are missing
Try these checks

The wiring diagram includes a buzzer, but the README component list and game sketch do not implement sound. Remove the buzzer from the diagram or add and test sound support separately before claiming audio features.