ESP32 S3 UNO multiple Button

This ESP32 S3 Uno multiple button tutorial shows you how to read several buttons at the same time on the ESP32 S3 Uno form board. Every button gets its own debounce, and the code never calls delay(), so no press is missed. The example uses five buttons, but you can change it to two buttons, three buttons, four buttons or more in a few seconds.
In this tutorial, you will:
- Wire five buttons to the ESP32 S3 Uno
- Debounce multiple buttons without the delay() function
- Detect when each button is pressed and released with the ezButton library
- Handle an array of buttons with a simple for loop
Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
ESP32 S3 Uno Pinout
The image below shows the pinout diagram of the ESP32 S3 Uno form board. Use it to find the Uno header pins (D2 to D6) and their GPIO numbers when you wire the buttons.

Wiring Diagram
One leg of each button goes to its own digital pin, and the other leg goes to GND. When you press a button, its pin reads LOW.

This image is created using Fritzing. Click to enlarge image
| Component Pin | ESP32 S3 Uno Pin |
|---|---|
| Button 1 (one leg) | D2 (GPIO18) |
| Button 2 (one leg) | D3 (GPIO17) |
| Button 3 (one leg) | D4 (GPIO19) |
| Button 4 (one leg) | D5 (GPIO20) |
| Button 5 (one leg) | D6 (GPIO3) |
| Button 1 to 5 (other leg) | GND |
WARNING
Button 5 uses D6 (GPIO3). This is a boot strapping pin on the ESP32 S3 Uno. The chip reads it at startup. A button to GND is normally safe, but do not hold button 5 down while you power on, reset or upload. If the board does not boot or upload, unplug the wire from D6, upload the code, then plug it back in.
※ NOTE THAT:
The ESP32 S3 Uno pins work at 3.3V and are NOT 5V tolerant. In this wiring the buttons only connect the pins to GND, so no 5V ever reaches the board.
Video Tutorial
Watch the video below to see this ESP32 S3 Uno project step by step.
FAQ
How many buttons can I connect to the ESP32 S3 Uno?
Each button needs one input pin, so the limit is the number of free pins. On the Uno headers you can use D2 to D13 and A0 to A5 as digital inputs. Avoid D0 and D1, because they carry the USB serial data. For many more buttons, use a button matrix or an I/O expander.
Do I need pull-up resistors for each button?
No. The ezButton library sets each pin to INPUT_PULLUP, so the internal pull-up resistor of the ESP32 S3 Uno keeps the pin HIGH. A press connects the pin to GND and the pin reads LOW. Just wire one leg to the pin and the other leg to GND.
Can I wire the buttons to 5V instead of GND?
No. The ESP32 S3 Uno pins work at 3.3V and are NOT 5V tolerant. If you wire a button between a pin and 5V, a press puts 5V on the pin and can damage it. Wire the buttons to GND as shown in this tutorial.
Why do my buttons print "pressed" many times for one press?
That is contact bounce. The metal inside the button jumps a few times before it settles. The code sets a 100 ms debounce time with setDebounceTime(), which hides the bounce. If you still see double presses, raise the value to 150 or 200.
Is button 5 on D6 safe to use?
Yes, in most cases. D6 is GPIO3, a boot strapping pin, but a button to GND does not change the boot as long as you do not hold it during power on or upload. If you have trouble, move button 5 to a free pin and change BUTTON_PIN_5 in the code.
What if my project needs more buttons than the Uno headers give?
The ESP32 S3 Uno has two extra rows of holes with more GPIOs. GPIO15 and GPIO16 (I/O, PWM, analog), GPIO45 and GPIO35 to GPIO42 (I/O, PWM), and GPIO47/GPIO48 (output only, PWM). Solder pin headers to use them, and write the GPIO number in the code, for example #define BUTTON_PIN_6 35. For buttons, GPIO15, GPIO16 and GPIO35 to GPIO42 are the best choice. Do not use GPIO47/GPIO48, because they are output only. Also be careful with two warnings. First, GPIO47/GPIO48 may run at 1.8V instead of 3.3V on some modules (especially ones with "V" in the name, like R8V or R16V), so 3.3V devices can be damaged or act strangely. Second, GPIO0, GPIO3 (D6), GPIO45 and GPIO46 (D9) are boot strapping pins, and a wrong connection can stop the board from booting or uploading code. Use the other extra pins first.
Troubleshooting
| Problem | Possible Cause | Solution |
|---|---|---|
| No COM port in the Arduino IDE | USB driver missing or board not in upload mode | Install the CP210x or CH340 driver, try another USB cable, or hold BOOT while you press RESET |
| Upload fails or board does not start | Button 5 on D6 (GPIO3) held down during reset or upload | Release all buttons while you upload, or unplug the D6 wire and plug it back after upload |
| One button never prints anything | Loose wire, wrong pin, or button legs on the same side of the breadboard gap | Check the wiring, check the pin number in the code, and place the button across the breadboard gap |
| A button prints pressed all the time | Button wired to 3.3V instead of GND, or legs that are always connected | Wire the other leg to GND and rotate the button 90 degrees on the breadboard |
| One press prints many times | Debounce time too short | Increase the value in setDebounceTime(), for example to 150 or 200 |
| Compile error about ezButton.h | ezButton library not installed | Install ezButton by ArduinoGetStarted.com from the Library Manager |
| Serial Monitor shows strange characters | Wrong baud rate | Set the Serial Monitor to 9600 baud to match Serial.begin(9600) |
