Button Input - Reading Digital Signals on ESP32
Learn how to read button presses and control outputs using the ESP32's GPIO pins. Understanding digital input is fundamental to creating interactive electronics projects.
What is Digital Input?
Digital input allows your ESP32 to read the state of external components like buttons, switches, and sensors. Unlike analog input which reads a range of values, digital input only recognizes two states:
- HIGH Logic 1 = 3.3V (button pressed with pull-down)
- LOW Logic 0 = 0V/GND (button not pressed with pull-down)
The Floating Pin Problem
When a GPIO pin is not connected to anything definite (neither 3.3V nor GND), it becomes a "floating pin". Floating pins pick up random electrical noise and give unpredictable readings!
Solution: Use pull-up or pull-down resistors to give the pin a defined default state!