Working with two LEDs and two PUSH BUTTONs

Working with two LEDs and two PUSH BUTTONs © GPL3+

This project illustrates the use of two PUSH BUTTONS to operate two LEDs

  • 807 views
  • 1 comment
  • 5 respects

Components and supplies

Apps and online services

About this project

This project demonstrates the use of two LEDs along with two Push Buttons.

Objective

For one set of LED and the Push button, when button is pressed LED is set ON and when the button is released, LED will be set OFF. for the other set, its the opposite effect.

Working with two LEDs and two PUSH BUTTONs

Code

Two LEDs and Two Push Buttons with opposite effectArduino
Two LEDs and Two Push Buttons with opposite effect
const int BUTTON1 = 2;
const int BUTTON2 = 4;
const int LED1 = 8;
const int LED2 = 12;
int BUTTONstate1 = 0;
int BUTTONstate2 = 0;

void setup()
{
  pinMode(BUTTON1, INPUT);
  pinMode(BUTTON2, INPUT);
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
}

void loop()
{
  BUTTONstate1 = digitalRead(BUTTON1);
  if (BUTTONstate1 == HIGH)
  {
    digitalWrite(LED1, HIGH);
  } 
  else{
    digitalWrite(LED1, LOW);
  }
  BUTTONstate2 = digitalRead(BUTTON2);
  if (BUTTONstate2 == HIGH)
  {
    digitalWrite(LED2, LOW);
  } 
  else{
    digitalWrite(LED2, HIGH);
  }
}

Schematics

Breadboard Diagram
Make connections as shown in the figure.
2leds 2pushbuttons qrzfpjkzfk

Comments

Similar projects you might like

Working with Shift Register

by SBR

  • 3,507 views
  • 2 comments
  • 8 respects

Switching Using Transistor

by SBR

  • 7,882 views
  • 15 comments
  • 36 respects

Arduino Door Bell with 3 LEDs

Project showcase by Team abhishekghosh

  • 4,615 views
  • 2 comments
  • 8 respects

Arduino Burglar

Project showcase by paolo_cravero

  • 3,870 views
  • 2 comments
  • 8 respects

Blinking LEDs with Arduino

Project tutorial by Super Kid

  • 3,919 views
  • 2 comments
  • 17 respects

10 Buttons Using 1 Interrupt

Project tutorial by Svizel_pritula

  • 31,228 views
  • 12 comments
  • 74 respects
Add projectSign up / Login