#include //include library code Servo myServo; //servo object const int potPin = A0; //potentiometer attached to analog pin 0 const int servoPin = 9;//servo attached to digital pin 9 int potVal;//declare variable int angle; //declare variable //************************************ void setup() { myServo.attach(servoPin); // servo attahed to servo object Serial.begin(9600);//initialise serial communication on 9600 bps } void loop() { potVal = analogRead(potPin); // value from potentiometer pin Serial.print("potVal: ");//print value of potentiometer in serial monitor Serial.print(potVal); angle = map(potVal, 0, 1023, 0, 179);// change values from 0-1023 to 0-179 Serial.print(", angle: ");//print angle of potentiometer in serial monitor Serial.println(angle); myServo.write(angle);//turn servo arm to angle set by potentiometer delay(15); // delay set for 15 microseconds }