#include <Servo.h>
Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards
int pos = 0; // variable to store the servo position
void setup() {
myservo.attach(11); // attaches the servo on pin 9 to the servo object
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
//remap sensorValue from 0-1024 to 0-255
pos = map(sensorValue, 0, 1024, 0, 179);
// tell servo to go to position in variable 'pos'
myservo.write(pos);
// print the value of variable "pos"
Serial.println(pos);
}