Stairway Lightning Switch With Arduino

by PanosA6 in Circuits > Arduino

1049 Views, 2 Favorites, 0 Comments

Stairway Lightning Switch With Arduino

Simple Stairway Lightning Switch  with Arduino
AND_GATE_bb.jpg
gate_and copy.jpg
/*******************************************
TITLE: A simple stairway lightning switch with delay
Created by: P.Agiakatsikas DATE: 11/01/17 *********************************************/
int buttonPin1 = 2; //Push button 1
int buttonPin2 = 3; //Push button 2
int ledPin = 8; // The outputlight
int buttonStatus1 = 0;
int buttonStatus2 = 0;
void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(buttonPin1, INPUT);
  pinMode(buttonPin2, INPUT);
}
void loop(){
  buttonStatus1 = digitalRead(buttonPin1);
  buttonStatus2 = digitalRead(buttonPin2);
if (buttonStatus1 == HIGH || buttonStatus2 == HIGH) { 
  // if one or the other push button is pressed the light will open according to the delay time
  digitalWrite(ledPin, HIGH);
  delay(10000);// delay time 10 sec
  digitalWrite(ledPin, LOW);
}
}