Reading a button press with Arduino is a fundamental skill in embedded programming. Here’s how to do it step by step:
What You Need:
Wiring the Button (with Pull-Down Resistor):
Add a 10kΩ resistor between pin 2 and GND
→ When the button is pressed, pin 2 reads HIGH
Basic Code: Detect Button Press
Alternate Wiring: Internal Pull-Up (No Resistor Needed)
Note: Now LOW = pressed, HIGH = unpressed (inverted logic)
Summary: