Learning Objective: Understand how to read digital input from push buttons using Arduino Uno, including pull-down and pull-up resistor configurations, and implement debouncing techniques.
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 outdigitalWrite(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