Push button
tactile switch 6×6 mm
A momentary switch — closes the contact only while pressed. The basic digital input.
Open the course →How it works
The four legs are two pairs: 1–3 and 2–4 are permanently joined inside. When you press, 1–2 is joined too (i.e. all four). The ESP32 pin must have a defined state when the button is NOT pressed — that is what a pull-up resistor is for. The ESP32 has one built in: pinMode(pin, INPUT_PULLUP). Then the pin reads 1 (HIGH) when released and 0 (LOW) when pressed (the button connects it to GND).
Pins and wiring
| Pin | What it is | Where it connects / why |
|---|---|---|
| Leg 1 / 3 | Internally connected pair | One side of the switch → GPIO pin. |
| Leg 2 / 4 | Internally connected pair | Other side → GND. |
Specifications
Size6×6 mm, leg spacing 6.5 × 4.5 mm
Current50 mA max
Life~100 000 presses
Tips and typical mistakes
- On the breadboard put the button ACROSS the groove and connect diagonally opposite legs — that way you are sure to use the switching pair.
- "Debouncing": when pressed, the contact bounces for a few milliseconds and the ESP32 sees several presses. Solution: ignore changes for the next 50 ms.
- GPIO 34–39 have NO internal pull-up — for a button use other pins or an external 10 kΩ resistor.