Arduino / Beginner

Turn a knob into a useful Arduino reading

Wire a potentiometer as a voltage divider, inspect its raw readings, and turn them into a simple percentage.

By Harry Avraamides10 October 202630 min activity

Before you start
Breadboard wiring and uploading a sketch to an Arduino UNO R3.

You will leave with
A serial readout that shows a knob position as a raw value and a percentage.

A potentiometer makes a good first adjustable input because you can see the shaft move and compare it with a number. The goal here is a stable measurement you understand, before connecting it to a motor or menu. This is an untested educational procedure for an Arduino UNO R3 using its default analog reference.

Gather and identify the parts

Use an UNO R3, USB cable, breadboard, three jumpers, and a 10 kΩ linear potentiometer suitable for breadboard wiring. You also need the Arduino IDE and Serial Monitor. The two end terminals connect across the resistive track. The wiper moves along that track; confirm its terminal from the component drawing rather than assuming every package uses the same layout.

In this example, the wiper voltage remains between the UNO’s GND and 5V rails. Do not attach an external voltage source to A0. Arduino documents the divider arrangement in its analog input tutorial.

1. Wire the voltage divider

  1. Unplug USB. Put the potentiometer where its three terminals occupy separate electrical groups on the breadboard.
  2. Connect one track end to UNO GND and the other track end to UNO 5V.
  3. Connect the wiper to A0. Inspect for a misplaced leg or jumper joining 5V directly to GND.
  4. Reconnect USB only after checking each connection against the terminal diagram.

2. Read without slowing everything down

unsigned long lastSample = 0;

void setup() {
  Serial.begin(9600);
}

void loop() {
  const unsigned long now = millis();
  if (now - lastSample >= 100UL) {
    lastSample = now;
    const int raw = analogRead(A0);
    const int percent = (raw * 100L + 511L) / 1023L;
    Serial.print("raw=");
    Serial.print(raw);
    Serial.print("  position=");
    Serial.print(percent);
    Serial.println("%");
  }
}

Open Serial Monitor at 9600 baud. On the UNO R3, the default conversion returns a 10-bit value from 0 to 1023. The long integer multiplication avoids overflowing the UNO’s smaller integer type when calculating the percentage. Rounding the result does not make the underlying measurement more accurate.

3. Make a measurement table

  1. Move slowly toward one end stop without forcing it. Record the lowest typical reading.
  2. Move to the opposite end and record the highest. Turn back to roughly the middle and note the reading there.
  3. Leave the knob untouched and observe how much the last few counts vary.
  4. Repeat the three positions. Look for a smooth progression, not an exact number for a guessed shaft angle.

If the direction feels backwards, disconnect power and swap only the two end-terminal wires. Keep the wiper on A0. Endpoints slightly away from 0 or 1023 do not automatically indicate a fault; wiring resistance, component behaviour, and the measurement system can affect results.

Troubleshoot before adding smoothing

A reading stuck at one end suggests an incorrect wiper connection or a short to a rail. Large random jumps can mean the wiper is disconnected. Inspect and reseat the wiring with power removed. A small amount of variation is different from a broken connection: do not hide a hardware fault behind averaging.

For a user interface, you can later add a dead band so tiny changes do not continually update a setting. First save the raw observations; they tell you how wide that band needs to be. This percentage is a relative knob position, not a calibrated voltage, physical angle, or motor-speed measurement. Keep actuation separate until the input works consistently.

Reference exercise · Read the evidence and checking record.

Your privacy, your choice.

This site currently loads no advertising or optional analytics scripts. Hosting includes aggregate traffic statistics and essential site-delivery functions. Optional services are off by default; changing these preferences does not activate them.

EssentialSite delivery and your saved privacy choices.Always on

Read the privacy notice