Projects / Knob-controlled servo

Knob-controlled servo

Beginner35 minGuided buildReviewed
Arduino Uno5VA0D9GNDPotentiometer90°SG90 servo
raw=512 angle=90

Tap a part to see what it does.

Tap the parts to see what each one does. A teaching simulation, not a circuit simulator.

Build it step by step

0 of 5 done
  1. UNO

    Place the potentiometer

    Three pins in three separate rows.

  2. UNO

    Make the divider

    Outer pins to 5V and GND, middle pin to A0.

  3. UNO59°

    Connect the servo

    Brown to GND, red to 5V, orange to D9.

  4. UNO59°

    Add the capacitor

    100 µF across the servo's 5V and GND, the stripe (minus) to GND.

  5. UNO

    Upload and turn

    Upload and turn the knob slowly from end to end.

In short

How do you build a knob-controlled servo?

Turn a potentiometer and an SG90 servo follows, from 0 to 180 degrees. You need Arduino Uno R3, SG90 Micro Servo, Potentiometer 10 kΩ, Electrolytic Capacitor 100 µF and Breadboard 830 Tie Points. It takes 5 steps and about 35 minutes.

Level
Beginner
Time
About 35 min
Parts
5

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
Pot outer pinsUno 5V and GNDDivider
Pot wiperUno A0Knob position
Servo brownGNDGround
Servo red5VServo power (one SG90 only)
Servo orangeUno D9Control signal
100 µF capacitorAcross servo 5V and GND, minus to GNDSmooths current spikes

Code

Arduino IDE, board "Arduino Uno". Servo library is built in.

Runs on a virtual Arduino Uno in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

#include <Servo.h>

Servo arm;
const int POT = A0;

void setup() {
  arm.attach(9);
  Serial.begin(9600);
}

void loop() {
  int raw = analogRead(POT);
  int angle = map(raw, 0, 1023, 0, 180);
  arm.write(angle);
  Serial.print("raw="); Serial.print(raw);
  Serial.print(" angle="); Serial.println(angle);
  delay(20);
}

What the serial monitor should show

Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual Arduino Uno with its sensors at their default values. Your numbers will follow your real readings, but the format should match.

raw=512 angle=90
raw=513 angle=90
raw=512 angle=90
raw=513 angle=90
raw=512 angle=90
raw=511 angle=89

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Knob fully leftangle=0, horn at one end
Knob fully rightangle=180, horn at the other end
Knob in the middleangle about 90

If it does not work

Servo jitters or the board resets

Add the 100 µF capacitor, or power the servo from a separate 5 V supply with a shared GND.

Servo does not move

Check orange goes to D9 and arm.attach(9) matches.

Angle only covers half the range

Check the pot's outer pins go to 5V and GND, not 3.3V.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the knob-controlled servo?

Arduino Uno R3, SG90 Micro Servo, Potentiometer 10 kΩ, Electrolytic Capacitor 100 µF and Breadboard 830 Tie Points.

How long does the knob-controlled servo take to build?

About 35 minutes for a beginner maker, in 5 steps.

How do I know the knob-controlled servo works?

Knob fully left: angle=0, horn at one end. Knob fully right: angle=180, horn at the other end. Knob in the middle: angle about 90.

Servo jitters or the board resets: what should I check?

Add the 100 µF capacitor, or power the servo from a separate 5 V supply with a shared GND.

Servo does not move: what should I check?

Check orange goes to D9 and arm.attach(9) matches.

Angle only covers half the range: what should I check?

Check the pot's outer pins go to 5V and GND, not 3.3V.