Introduction
In this project, we will learn how to control an LED using a push button with Arduino. This is one of the most basic and important projects for beginners in electronics and Arduino. By doing this project, students can understand how digital input and digital output work in Arduino.
Components Required
-
Arduino Uno
-
Push Button
LED
220 Ω Resistor
-
10 kΩ Resistor (for button – optional)
-
Breadboard
-
Connecting Wires
Circuit & Description
- Connect one side of the push button to 5V.
Connect the LED to pin 13, using a resistor 220Ω connect the other LED pin to the ground of Arduino
-
Connect the other side of the button to pin 2 of Arduino.
-
Connect a 10 kΩ resistor from pin 2 to GND (pull-down resistor).
This pull-down resistor ensures that the input pin reads LOW when the button is not pressed.
Arduino Program
Working Principle
-
Arduino continuously reads the state of the push button using
digitalRead(). -
When the button is pressed, the input pin becomes HIGH.
-
Arduino sends HIGH signal to LED pin using
digitalWrite(). -
The LED glows.
-
When the button is released, the input becomes LOW and the LED turns OFF.
Alternative Method (Using Internal Pull-up Resistor)
We can avoid using an external 10kΩ resistor by using Arduino’s internal pull-up resistor.
Change this line in setup():
And modify the logic:
Note: Logic is inverted because of pull-up resistor.
Applications
-
Door bell switch
-
Keyboard keys
-
Control systems
-
Digital input testing
-
Student practice project
Advantages
-
Very simple project
-
Easy to understand
-
Low cost
-
Good for beginners
Conclusion
This project helps beginners understand how a push button works with Arduino and how to control an LED using digital input. It is an important base project before learning sensors, relays, and motors.