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

  • 138 views
  • 0 comments
  • 1 respect

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

Blinking LEDs with Arduino

Project tutorial by Super Kid

  • 3,238 views
  • 2 comments
  • 16 respects

Switching Using Transistor

by SBR

  • 32 views
  • 0 comments
  • 0 respects

Arduino Door Bell with 3 LEDs

Project showcase by Team abhishekghosh

  • 3,404 views
  • 2 comments
  • 6 respects

Arduino Burglar

Project showcase by paolo_cravero

  • 2,943 views
  • 2 comments
  • 7 respects

Turn LEDs On/Off via Remote Control

Project tutorial by ismystore

  • 7,773 views
  • 0 comments
  • 6 respects

Alexa Controlled LEDs Through Raspberry Pi

Project tutorial by vincent wong

  • 5,761 views
  • 6 comments
  • 26 respects
Add projectSign up / Login