//automatic gate operation- the car will detected and the gates should open)
#include <Servo.h>
int echopin = A0;
int trigpin =7;
int Time;
int Distance;
Servo myservo;
void setup()
{
pinMode(trigpin, OUTPUT);
pinMode(echopin, INPUT);
myservo.attach(11);
}
void loop()
{
digitalWrite(trigpin, LOW);
digitalWrite(trigpin, HIGH);
Time =pulseIn(echopin,HIGH);
Distance= Time * 0.0172;//formula for Distancetance
if (Distance>30)
{
myservo.write(90);//Angle of Rotation
}
else{
myservo.write(0);//Angle of Rotation
}
}