
Servo with a Potentiometer
Beginner25 minAs you turn a potentiometer's knob, an SG90 servo motor turns with it: one end of the knob is 0°, the other 180°. The angle the servo stops at is also written to the Serial Monitor. It teaches adding a library (Servo) to a project, turning a value read with analogRead into an angle with map, and sending a motor to the angle you want with servo.write. The Servo library comes with the Arduino IDE, so there is nothing to install.

What you need
1 × Arduino Uno R3
1 × Breadboard 830 Points (MB-102)
1 × SG90 Micro Servo Motor
1 × 10K Potentiometer
8 × Jumper Wire - Male/Male
Wiring steps
- 1
Connect the power rails (5V and GND)

Plug a black jumper wire into one of the GND pins on the Arduino's power header and connect its other end to the breadboard's top blue (−) rail. Plug a red jumper wire into the 5V pin on the same header and connect its other end to the top red (+) rail. Both the potentiometer and the servo are powered from these two rails.
- Arduino GND → the top blue (−) rail (black wire)
- Arduino 5V → the top red (+) rail (red wire)
- 2
Add and wire the potentiometer

Plug the potentiometer's three legs into columns 20, 21 and 22 in the top half. Connect column 20 to the top (−) rail with a short black wire and column 22 to the top (+) rail with a short red wire. Then connect the Arduino's A0 pin to the middle leg's column, column 21, with a yellow jumper wire (POT_PIN A0). As you turn the knob, the middle leg's voltage moves between 0 V and 5 V, which the Arduino reads as a number from 0 to 1023.
- potentiometer left leg → column 20, top half
- potentiometer middle leg → column 21, top half
- potentiometer right leg → column 22, top half
- column 20, top half → the top blue (−) rail (black wire)
- column 22, top half → the top red (+) rail (red wire)
- Arduino A0 → column 21, top half (yellow wire)
- 3
Connect the servo

Push one end of three male-male jumper wires into the three-hole plug at the end of the SG90's cable. Connect the one facing the brown (GND) wire to the top (−) rail, the one facing the red (5V) wire to the top (+) rail, and the one facing the orange (signal) wire straight to the Arduino's pin ~9 (SERVO_PIN 9). The servo works out which angle to turn to from the length of short pulses on its signal wire; the Servo library makes those pulses.
- servo brown (GND) lead → the top blue (−) rail (black wire)
- servo red (5V) lead → the top red (+) rail (red wire)
- Arduino pin 9 → servo orange (signal) lead (orange wire)
Arduino sketch
Download the sketch (.ino)Try it on Wokwi
// The Servo library ships with the IDE
#include <Servo.h>
// Middle leg of the potentiometer: A0
const int POT_PIN = A0;
// The servo's orange (signal) wire
const int SERVO_PIN = 9;
Servo servo;
int lastAngle = -1;
void setup() {
servo.attach(SERVO_PIN);
Serial.begin(9600);
}
void loop() {
// From 0 (one end) to 1023 (the other)
int potValue = analogRead(POT_PIN);
// Turn 0–1023 into 0–180 degrees
int angle = map(potValue, 0, 1023, 0, 180);
servo.write(angle);
// Write the angle when it changes
if (angle != lastAngle) {
Serial.print("Angle: ");
Serial.println(angle);
lastAngle = angle;
}
// Give the servo time to get there
delay(15);
}
What the Serial Monitor shows
Angle: 0 Angle: 45 Angle: 90 Angle: 135 Angle: 180
What you will see
As you turn the knob the servo's arm turns too: 0° at one end of the knob, 90° in the middle, 180° at the other end. The angle in the Serial Monitor changes with the knob. If the angle changes but the servo does not move, check that the orange wire is on pin ~9 and the red and brown wires are in the right rails. If the servo jitters or the Arduino restarts on its own, the servo is not getting enough current from USB: do not load the arm, and power the Arduino from an adapter if needed. If the angle never changes, check that the yellow wire is in the middle leg's column (21).
Similar projects
LED Brightness with a PotentiometerBeginner20 minSet an LED's brightness by turning a potentiometer's knob: with the knob at one end the LED is off, and it gets brighter as you turn towards the other end. The value read and the brightness given to the LED are also written to the Serial Monitor. It teaches reading an analog input with analogRead, turning one range into another with map, and using PWM with analogWrite. No extra library needed.Open project
Arduino-Free Dark-Activated LampBeginner25 minA night light with no Arduino and no code, built from just a 9V battery, a BC547 transistor, an LDR and a potentiometer: when it gets dark the LED lights by itself, and it goes out when the light comes back. With the potentiometer you set how dark it must be. It teaches three cornerstones of basic electronics: the voltage divider (the potentiometer and the LDR), the transistor as a switch that turns a large current on and off with a small base current, and limiting an LED's current with a resistor. You see how these parts, used in Arduino projects all the time, work without one.Open project
Digital VoltmeterBeginner20 minA voltmeter that measures between 0 and 5 V with the Arduino's analog input: as you turn the potentiometer, the voltage on pin A0 changes; the 16x2 LCD shows it in volts on its top row (e.g. 3.27 V) and as a bar filling from the left on its bottom row. It teaches how an analog reading (0–1023) turns into volts, how averaging readings steadies them, and how to teach the LCD characters of your own to draw a bar. Install "LiquidCrystal I2C" from the Library Manager.Open project
In the app, tick off every wire, match the parts to your inventory and pick up where you left off.
