Smart Door
Smart Door using Arduino Uno
YouTube: Video
Circuit:
Code:
int bulb = 13;
int ir1 = 6;
int ir2 = 7;
int count = 0;
void setup()
{
pinMode(bulb, OUTPUT);
pinMode(ir1, INPUT);
pinMode(ir2, INPUT);
Serial.begin(9600);
count = 0;
}
void loop()
{
if(digitalRead(ir1)== LOW && digitalRead(ir2)== HIGH)
{
count++;
Serial.print("Count:");
Serial.println(count);
delay(1000);
}
else if(digitalRead(ir2)== LOW && digitalRead(ir1)== HIGH)
{
count--;
Serial.print("Count:");
Serial.println(count);
delay(1000);
}
if(count > 0)
{
digitalWrite(bulb, HIGH);
//Serial.println("Lights ON");
}
else
{
digitalWrite(bulb, LOW);
//Serial.println("Lights OFF");
}
}
Comments
Post a Comment