Using a potentiometer to turn a servo via an arduino uno, and some code.

Here is the video

#include <Servo.h>

Servo myservo; // create servo object to control a servo

int sensorPin = A0; // select the input pin for the potentiometer
int servoPin = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
int val;

void setup() {



void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);

val = map(sensorValue, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
myservo.write(val); // sets the servo position according to the scaled value