Turn LED On / Off with 2 push Buttons using Arduino Uno

 Turn LED On / Off with 2 Push Buttons

 

Welcome to my new Tutorial, In this we will do Interfacing of LED with 2 push buttons. 

The very first Tutorial on this Arduino Platform is "How to Turn On and Off an LED using 2 Push Buttons with Arduino Uno

This is like Turning On an LED with 1 push button and Turning Off the same LED with other push button.

The Arduino reads the state of ON button and sends HIGH logic to turn ON the LED, whereas the Arduino reads the state of OFF button and sends HIGH Logic to turn OFF the LED. 

 


This Tutorial I have shown is using Proteus v8.11. I will upload a video using components later on my YT channel.


If you don't know How to Install Proteus v8.11, read my blog from below link👇👇

https://www.electronicsisfun08.in/2022/12/how-to-download-and-install-proteus.html

 Since YouTube has removed my video of How to download and install proteus, So you can download it from above link.

 

If you don't have the Arduino Libraries, then watch that separate video from below link👇👇

https://www.electronicsisfun08.in/2022/12/how-to-add-free-libraries-in-proteus.html 

 For more help on this How to add libraries of Proteus v8.11/v8.12 You can watch the video also.

 


 

 

Using 2 push buttons to Turn On and Off LED

 

Using 2 push buttons to Turn ON and OFf the same LED is a logic game. Like there are 2 push buttons, When you press On Push Button, the LED Turns On and when you press OFF push button, the same LED Turns OFF.

This is the basic tutorial in which you use 2 push button and this is simple tutorial.

 

Watch the video:-

 


 

WIRING DIAGRAM FOR 2 BUTTONs AND LED

 

Let’s start with a wiring diagram for this project.

In this Wiring Diagram, First connect an LED with Pin no. 13 of Arduino with a 330 ohm resistance to ground.

Now, connect ON push button with Pin no. 2 of Arduino to GND, and connect OFF push button with Pin no. 5 of Arduino to GND.

Connect 1K resistance from both push buttons to Vcc.

 


 

Parts List:- 

 

1. Arduino Uno :- https://amzn.to/3VSv8l6

2. Push Buttons :- https://amzn.to/3XhvvGG

3. LED :- https://amzn.to/3jO6559

4. Resistance Pack :- https://amzn.to/3XbimPy

5. Jumper Wires :- https://amzn.to/3vPi9WO

 

CODE FOR THE BUTTON AND LED

 

// https://www.youtube.com/channel/UCaXI2PcsTlH5g0et67kdD6g  //
// Turn On Off led with 2 push buttons  //
// By MOHD SOHAIL //
// ---------------------------------------------------------//



int led = 13;
int onbutton = 2;
int offbutton = 5;
int onvalue = 0;
int offvalue = 0;

void setup() {
  Serial.begin(9600);
  pinMode(led, OUTPUT);
  pinMode(onbutton, INPUT);
  pinMode(offbutton, INPUT);
}

void loop() {
  onvalue = digitalRead(onbutton);
  if ( onvalue == LOW )
  {
    digitalWrite(led, HIGH);
  }

  offvalue = digitalRead(offbutton);
  if ( offvalue == LOW )
  {
    digitalWrite(led, LOW);
  }
  }



If you have any query regarding this project, Contact me from below :

Telegram +919557024177
Instagram id : eif.08
Facebook page  : EIF08

 

Post a Comment

0 Comments