Code for Automated Hand Wash By Arduino Uno

Copy the Code here ----

#include <Servo.h> #define irsensor 3 // connect the IR sensor to PIN 3 Servo myservo; int pos = 0; // variable to store the servo position void setup() { myservo.attach(9); // attaches the servo on pin 9 pinMode(irsensor, INPUT); } void loop() { if(digitalRead(irsensor)==HIGH) { myservo.write(120); // tell servo to go to position '120' degree delay(15); // waits 15ms for the servo to reach the position } else { myservo.write(0); // tell servo to go to position '0' degree delay(15); } }

151 views

Recent Posts

See All