ESP32 OLED Stacker 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 Stacker arcade game using an ESP32 development board and a 128×64 OLED display. Touch the sensor to place moving blocks, preserve their overlapping sections, and build a tower toward the top.

The game features automatic overhang cutting, falling-block animation, screen shake, buzzer effects, a win screen, and a Game Over screen. Block movement becomes faster as the tower grows, increasing the timing challenge.

Before you power up

Disconnect USB power before wiring. Verify OLED voltage and check GPIO 12 boot behaviour with the buzzer connected.

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 block movement, touch handling, display updates, and buzzer timing.× 1
SSD1306 OLED Display128×64 I2C display renders the stack, moving block, and game screens.× 1
TTP223 Touch SensorProvides digital touch input to start, place blocks, and restart gameplay.× 1
BuzzerProduces tones for start, placement, cutting, winning, and Game Over events.× 1
BreadboardHolds modules and supports temporary circuit connections during assembly.× 1
Connecting WiresConnect OLED, touch sensor, buzzer, power, and common ground.× 10
USB CablePowers the ESP32 and uploads firmware from a 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, touch sensor, and buzzer on a stable surface. Identify each module's power, ground, and signal pins before beginning the wiring process.

The README specifies an SSD1306 128×64 I2C display at address 0x3C, but the supplied diagram labels the display SH1106. Verify the controller on your actual module.

1 of 5
04

Software & tools

Install these before uploading the firmware.

Arduino IDEEdits, compiles, and uploads the Stacker game firmware to ESP32.
ESP32 Board PackageAdds ESP32 Dev Module support and build configuration to Arduino IDE.
Adafruit GFX LibraryProvides drawing primitives and text-rendering functions for the game interface.
Adafruit SSD1306 LibraryInitializes and updates compatible SSD1306 OLED displays over I2C.
Wire LibraryProvides I2C communication between the ESP32 and OLED display.
Serial MonitorDisplays an OLED initialization error when configured at 115200 baud.
05

Expected output

Compare your build with the result described here.

FINAL CHECKPOINT

After upload, the OLED displays the STACKER start screen with a moving demo block and a PRESS TO START prompt. Serial Monitor at 115200 baud shows an error only if OLED initialization fails.

During play, the block moves horizontally, and touching places it and cuts any overhang. Movement becomes faster as rows increase, with a minimum delay of 25 milliseconds; reaching twelve rows wins.

06

Troubleshooting & fixes

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

01OLED remains blank or graphics look corrupted
Try these checks

Check OLED VCC, GND, SDA on GPIO 21, and SCL on GPIO 22. Confirm the actual display controller and address match the SSD1306 configuration, then inspect jumper wires and headers.

02Touch sensor does not register input
Try these checks

Check TTP223 VCC, GND, and OUT connections. Confirm OUT reaches GPIO 4 and becomes HIGH when touched; if your module uses active-LOW output, change TOUCH_ACTIVE_STATE in the sketch.

03ESP32 fails to boot or buzzer remains silent
Try these checks

Verify buzzer positive connects to GPIO 12 and negative to GND. GPIO 12 is a boot-strapping pin, so the attached circuit can affect startup on some boards; check boot reliability and buzzer compatibility.