// #include <Servo.h>
// Servo motor;
// int potpin = A0;
// int resistance;
// int angle;
// void setup() {
// Serial.begin(9600);
// motor.attach(9);
// }
// void loop() {
// resistance = analogRead(potpin);
// angle = map(resistance, 0, 1023, 0, 180);
// Serial.print(resistance);
// Serial.print(":");
// Serial.print(angle);
// Serial.println();
// motor.write(angle);
// delay(100);
// }
# include <Servo.h>
Servo myservo;
int potin = A0;
int val;
void setup() {
Serial.begin(9600);
myservo.attach(9);
}
void loop() {
val = analogRead(potin);
val = map(val, 0, 1023, 0, 180);
Serial.println(val);
myservo.write(val);
delay(100);
}