/* "Resist" This example demonstrates the servo drive movement depending on the value on the potentiometer */ #include Servo servo; // create an Servo class instance to control the servo int potpin = A0; // analog pin used to connect a potentiometer int val; // variable for reading the analog output value void setup() { servo.attach(8); // connecting the servo drive to digital pin 8 (D8) } void loop() { val = analogRead(potpin); // reading the potentiometer value (value from 0 to 4096) val = map(val, 0, 4096, 0, 180); // change scale for use with servo (value from 0 to 180) servo.write(val); // setting the servo position according to the value delay(15); // waiting for the servo to get there }