Automatic hand wash

TLMXB003

In the last few days, Jugaadu noticed that after having the food, his younger brother doesn't close the washbasin tap. To avoid wastage of water, Jugaadu decided to make something that only dispatches water when someone is in front of it. Can you help Jugaadu in it?
Networking and Digital
  1. Place the IR sensor in front of Tap.
  2. Connect IR module with Arduino, water pump module, battery and motor driver using connecting wires on bread-board.
  3. Program the Arduino and upload the sketch Using A to B USB Cable.
  4. Test it by power it on.

    

int ir=2;

int wp1=4;

int wp2=5;

void setup() {

pinMode(ir,INPUT);

pinMode(wp1,OUTPUT);

pinMode(wp2,OUTPUT);

Serial.begin(9600);

}

void loop() {

if(digitalRead(ir)==LOW){

 digitalWrite(wp1,HIGH);

digitalWrite(wp2,LOW);

Serial.println("wash your hand");

}

else{

digitalWrite(wp1,LOW);

digitalWrite(wp2,LOW);

Serial.println("no water");

}

}