#include <Servo.h>
Servo myServo;
const int analogPin = A0; //joystick
int value = 0;
void setup() {
pinMode(analogPin, INPUT);
Serial.begin(9600);
myServo.attach(9);
}
void loop() {
//Read in 10-bit analog value (0 to 1023) from joystick
value = analogRead(analogPin);
//value variable will convert to degrees
//Use map() to convert values to degrees (0 to 180) for Servo motor
value = map(value, 0, 1023, 0, 180);
//Use the converted value to move the Servo
myServo.write(value); //Move to a position specified by value (0 to 180)
delay(15); //Then wait 15ms
}//loop