SERVO WITH IR SENSOR

Sanitizer dispenserServo

The code can be downloaded at:

https://github.com/triantara/ARDUINO-TRIANTARA/blob/main/SERVO_IR_SENSOR.zip

#include <Servo.h>
Servo head;

void setup()
{
Serial.begin(9600);
head.attach(5);
head.write(90);

}
unsigned long last = millis();
void loop()
{
int sensorValue0 = analogRead(A0);
if (sensorValue0 < 100)
{

if (millis() – last > 250) {
head.write(180);
delay(1500);
head.write(90);
delay(100);
}
last = millis();
}
else
{
head.write(90);
}
}