This project turns an ESP32 microcontroller into a five-button game controller that sends input states over serial communication. The controller reads five push buttons wired to GPIO pins with debouncing logic to filter out electrical noise, ensuring clean and reliable input detection.
The guide includes a wiring diagram showing how to connect each button to the ESP32, a complete parts list, and ready-to-use firmware with built-in debouncing. Builders will have a functional controller that outputs button states at regular intervals, suitable for custom games, simulations, or interactive applications.
Wiring diagram

Gather all the parts
Assemble it in 1 step
1. Wire the five buttons
With USB unplugged, connect one switched terminal of each button to GND. Connect the other terminal to GPIO25 for Up, GPIO26 for Down, GPIO27 for Left, GPIO32 for Right, and GPIO33 for Action. Use a breadboard ground rail linked to ESP32 GND if you need more ground connections.
- On four-leg tactile switches use terminals that connect only when pressed.
Review all connections
1. Connections between "up" and "ESP32"
2. Connections between "down" and "ESP32"
3. Connections between "left" and "ESP32"
4. Connections between "right" and "ESP32"
5. Connections between "action" and "ESP32"
Deploy the firmware
#include <Arduino.h>
constexpr uint8_t pins[]={25,26,27,32,33};
uint8_t raw=0, stable=0;
uint32_t changed=0, sent=0;
void setup(){Serial.begin(115200); for(auto p:pins) pinMode(p,INPUT_PULLUP);}
void loop(){
uint8_t mask=0; for(unsigned i=0;i<5;i++) if(!digitalRead(pins[i])) mask|=1<<i;
auto now=millis();
if(mask!=raw){raw=mask;changed=now;}
if(now-changed>=20) stable=raw;
if(now-sent>=40){sent=now;Serial.printf("D:%u\n",unsigned(stable));}
delay(1);
}Remix this project
Make it yours in one click
Open a full copy of this project in your own Schematik workspace, diagram, code, parts, and assembly steps included. Swap the sensor, add features, or redesign the whole thing with AI. The author's original stays untouched.




