Site icon Circuit Ideas for You

Push Button LED Circuit using Arduino

This simple Push Button LED Circuit using Arduino shows how to turn an LED ON and OFF using a push button switch.

When we press the button, the LED turns ON, and when you release it, the LED turns OFF; furthermore, this project helps beginners learn about digital input and output in Arduino.

Arduino Coding:

int led = 13;
int button = 2;
int buttonstate = 0;

void setup() {
pinMode(led, OUTPUT);
pinMode(button, INPUT);
}

void loop() {
buttonstate = digitalRead(button);
if (buttonstate == HIGH) {
digitalWrite(led, HIGH);
} else {
digitalWrite(led, LOW);
}
}

Code Explanation:

Circuit Working:

Push Button LED Circuit Diagram using Arduino

Parts List:

ComponentsValuesQuantity
Resistors220Ω 1/4 watt1
10k 1/4 watt1
SemiconductorsArduino UNO Board1
LED 5mm any color1
Push Button Switch1

When we do not press the button, pin 2 stays LOW and the LED remains OFF; when we press the button, it supplies 5 V to pin 2.

After that, Arduino reads HIGH and LED turns ON and when button released then pin 2 goes LOW again and and LED turns OFF.

Formula:

Below is the formula for Push Button LED Circuit:

Current through LED = V / R = 5V / 220 ohm = 0.022a = 22ma

The circuit uses a 220Ω resistor for the LED, which requires about 20ma of current and additionally, the circuit uses a 10kΩ resistor to keep the input low when no one presses the button.

How to Build:

To build a Push Button LED Circuit using Arduino follow the below steps for connection:

Conclusion:

Overall, this project if for Push Button LED Circuit using Arduino, as it shows how to control an led with a push button using Arduino; also circuit is simple and helps to learn digital input and output basics easily

Exit mobile version