#include <Servo.h>
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:
int x = analogRead(A0);
int y = map(x,0,1023,0,180);
servo.write(y);
Serial.println(y);
/*
servo.write(0);
Serial.println("The angle is 0 degree");
delay(2000);
servo.write(90);
Serial.println("The angle is 90 degree");
delay(2000);
servo.write(180);
Serial.println("The angle is 180 degree");
delay(2000);
*/
delay(1000);
}