20 sec timer for washing hand



pin connection 
   1.led1--2
   2.led2--3
   3.led3--4
   4.ir module --5


code:

int rled= 2;
int gled= 3;
int bled= 4;
int ir= 5;

void setup() {
  // put your setup code here, to run once:

  pinMode(rled,OUTPUT);
pinMode(gled,OUTPUT);
pinMode(bled,OUTPUT);
pinMode(ir,INPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  int irv = digitalRead(ir);
  
if(irv == 0)
{
digitalWrite(rled,LOW);
digitalWrite(gled,LOW);
digitalWrite(bled,LOW);
}
else
{
digitalWrite(rled,HIGH);
delay(1500);
for(int i=0;i<10;i++)
{
digitalWrite(gled,HIGH);
delay(1000);
digitalWrite(gled,LOW);
delay(1000);

}
digitalWrite(bled,HIGH);
delay(1600);

}

youtube video:


No comments:

Post a Comment

Timer control led using esp32

...