Skip to content

Button Input - Reading Digital Signals

Beginning of the lesson

What is Digital Input?

In our previous lessons, we learned how to send signals OUT from Arduino to control LEDs. Now we'll learn how to receive signals IN from the outside world using push buttons!

Digital Output (Previous Lesson)

Arduino sends signals to control things:

  • digitalWrite(pin, HIGH) → Sends 5V out
  • digitalWrite(pin, LOW) → Sends 0V out
  • Example: Turning LEDs on/off
Digital Input (This Lesson)

Arduino receives signals to detect events:

  • digitalRead(pin) → Returns HIGH or LOW
  • HIGH = 5V detected (button pressed)
  • LOW = 0V detected (button released)

The Floating Pin Problem

Before we connect a button, we need to understand a critical concept: floating pins.

What happens if we just connect a button between 5V and a pin?

When the button is pressed, the pin sees 5V (HIGH). But when released, the pin is connected to nothing - it "floats" and picks up random electrical noise, giving unpredictable readings!

Floating Pin Signal Visualization
Interactive visualization — available in the full lesson

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