#include <Servo.h>
int echopin = A0;
int trigpin = 7;
int Time;
int Distance;
Servo myservo;
void setup() {
// put your setup code here, to run once:
pinMode(trigpin, OUTPUT);
pinMode(echopin, INPUT);
myservo.attach(11);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(trigpin, LOW);
digitalWrite(trigpin, HIGH);
int value = pulseIn(echopin, HIGH);
Distance = Time * 0.0172;
if (Distance > 30){
myservo.write(90);
} else {
myservo.write(0);
}
}