A potentiometer is a knob that gives a voltage. It sets speeds, volumes, thresholds and servo angles, and it is the easiest way to see how the Nano’s analog input works.
The outer legs go to GND and 5V, the middle (wiper) to A6. The sketch prints the raw reading, voltage and position, and uses the knob to set how fast the on-board LED blinks.
Wiring
| Arduino Nano | Rotary potentiometer (10 kΩ, B10K) | Wire | Notes |
|---|---|---|---|
| GND | Pin 1 | black | |
| A6 | Wiper | yellow | |
| 5V | Pin 3 | red |
Passive — across the board’s 3.3 V or 5 V part, 5 V board. Connect the outer legs to the same voltage your ADC uses: 3.3 V and GND on ESP32 and Pico, 5 V and GND on Uno. The wiper can then never exceed the pin limit.
Board quirks
- A6/A7 on the Nano are analog inputs only — a potentiometer is the perfect job for them, and it keeps A0–A5 free.
- The ADC is 10-bit: 0–1023 across 0–5 V, about 4.9 mV per step. Readings jitter by ±1–2 counts; average them if you need a steady value.
- Swap Pin 1 and Pin 3 if turning clockwise lowers the value.
- The Nano’s 5 V on USB is often 4.6–4.8 V. The raw reading is a ratio of the supply, so position in % is still right; the volts figure is approximate.
Code
// 10 kΩ potentiometer on an Arduino Nano's analog-only pin A6, setting the on-board LED's blink rate.
// Pin 1 → GND, Wiper → A6, Pin 3 → 5V.
const uint8_t POT_PIN = A6;
void setup() {
Serial.begin(115200);
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
int raw = analogRead(POT_PIN); // 0-1023
unsigned int period = map(raw, 0, 1023, 50, 1000); // ms per half-blink
static unsigned long lastBlink = 0, lastPrint = 0;
if (millis() - lastBlink >= period) {
lastBlink = millis();
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
}
if (millis() - lastPrint >= 300) {
lastPrint = millis();
Serial.print(F("Raw: "));
Serial.print(raw);
Serial.print(F(" Voltage: "));
Serial.print(raw * 5.0 / 1023, 2);
Serial.print(F(" V Position: "));
Serial.print(map(raw, 0, 1023, 0, 100));
Serial.print(F(" % Blink: "));
Serial.print(period);
Serial.println(F(" ms"));
}
}// 10 kΩ potentiometer on an Arduino Nano's analog-only pin A6, setting the on-board LED's blink rate.
// Pin 1 → GND, Wiper → A6, Pin 3 → 5V.
const uint8_t POT_PIN = A6;
void setup() {
Serial.begin(115200);
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
int raw = analogRead(POT_PIN); // 0-1023
unsigned int period = map(raw, 0, 1023, 50, 1000); // ms per half-blink
static unsigned long lastBlink = 0, lastPrint = 0;
if (millis() - lastBlink >= period) {
lastBlink = millis();
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
}
if (millis() - lastPrint >= 300) {
lastPrint = millis();
Serial.print(F("Raw: "));
Serial.print(raw);
Serial.print(F(" Voltage: "));
Serial.print(raw * 5.0 / 1023, 2);
Serial.print(F(" V Position: "));
Serial.print(map(raw, 0, 1023, 0, 100));
Serial.print(F(" % Blink: "));
Serial.print(period);
Serial.println(F(" ms"));
}
}Expected serial output
Raw: 0 Voltage: 0.00 V Position: 0 % Blink: 50 ms
Raw: 512 Voltage: 2.50 V Position: 50 % Blink: 524 ms
Raw: 1023 Voltage: 5.00 V Position: 100 % Blink: 1000 msRaw: 0 Voltage: 0.00 V Position: 0 % Blink: 50 ms Raw: 512 Voltage: 2.50 V Position: 50 % Blink: 524 ms Raw: 1023 Voltage: 5.00 V Position: 100 % Blink: 1000 ms
Common errors
Value jumps around
Loose breadboard contact on the wiper, or a worn carbon pot. Twist the pot’s legs firmly into the breadboard or solder wires.
Only reads 0 or 1023
Wiper and an outer leg swapped. The wiper is the middle pin.