Skip to content

Button Input - Reading Digital Signals on ESP32

Beginning of the lesson

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)
Key Concept: The ESP32 reads voltage levels on GPIO pins. When voltage is close to 3.3V, it reads HIGH. When close to 0V, it reads LOW.

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!

Interactive visualization — available in the full lesson

Solution: Use pull-up or pull-down resistors to give the pin a defined default state!

Continue this lesson on YourAIZone

The full lesson has the complete explanation, worked examples, common mistakes, tests with instant checking and an AI tutor. Start right away as a guest, or create an account to keep your progress.

In the full lesson

  • The complete explanation
  • Worked examples
  • Common mistakes and how to avoid them
  • Test questions: 15
  • AI tutor that answers questions about the topic
  • Progress tracking for students, parents and teachers