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

    

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");

}

}