#include<Servo.h>
#include <Ultrasonic.h>
Ultrasonic sensor(10,8);
int mesafe;
Servo servo;
void setup() {
// put your setup code here, to run once:
servo.attach(9);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
mesafe=sensor.read();
delay(500);
Serial.print(mesafe);
if (mesafe>=45){
servo.write(90);
}
else{
servo.write(0);
}
}