#include <Servo.h>
Servo myServo;
int potPin = A0; //port connect to potensionmeter
int val;
int inVal;
void setup() {
// put your setup code here, to run once:
myServo.attach(9);
}
void loop() {
//value of the potentiometer (value between 0 and 1023)
inVal = analogRead(potPin);
//scale it to use it with the servo (value between 0 and 180)
val = map(inVal,0,1023,0,180);
// sets the servo position according to the scaled value
myServo.write(val);
delay(2000);
}