#include
int pin = 7;
int val = 0;
Servo myservo;
unsigned long duration;
void setup()
{
pinMode(pin, INPUT);
//pinMode(9, OUTPUT);
myservo.attach(9);
}
void loop()
{
duration = pulseIn(pin, HIGH);
duration = map(duration,1160,1780,0,179);
myservo.write(duration);
}