How do I connect a potentiometer to an Arduino?
Outer pins to 5V and GND, middle pin (the wiper) to an analog input such as A0. analogRead(A0) then returns 0 to 1023.
Reading a potentiometer and dimming an LED is the classic first analog input and output project on an Arduino. The diagram shows only the board pins the circuit uses, the way you would draw it in a project schematic.
The potentiometer's two ends go to 5V and GND, so its track is a voltage divider across the supply. The wiper picks off any voltage between 0 and 5 V as you turn the knob, and A0 reads it.
The Uno's analog-to-digital converter turns 0 to 5 V into a number from 0 to 1023, about 4.9 mV per step. A 10 kΩ pot draws 0.5 mA and presents at most 2.5 kΩ at the wiper, under the 10 kΩ source resistance the Uno's ATmega328P is designed for.
D9 is one of the Uno's PWM pins. analogWrite(9, value) switches it between 0 and 5 V about 490 times a second, with value from 0 to 255 setting the fraction of time it is high. That is too fast to see, so the LED simply looks dimmer or brighter.
R1 limits the LED current while D9 is high to about (5 V − 2 V) / 220 Ω ≈ 14 mA, under the 20 mA usually recommended per Uno pin. The sketch needs one line in loop(): analogWrite(9, analogRead(A0) / 4), which scales the 0 to 1023 reading to the 0 to 255 PWM range.
VA0 = 5 V × wiper position (0 to 1)reading = VA0 / 5 V × 1023I = (5 V − 2 V) / 220 Ω ≈ 14 mAIavg ≈ 14 mA × value / 255At analogWrite(9, 128) the LED averages about 7 mA.
| Ref | Part | Value | What it does |
|---|---|---|---|
| A1 | IC / module | Arduino Uno | Arduino Uno. Only the four pins the circuit uses are drawn. |
| D1 | LED | Red | Red LED, anode toward R1. |
| R1 | Resistor | 220 Ω | 220 Ω LED resistor. |
| RV1 | Potentiometer | 10 kΩ | 10 kΩ linear potentiometer. |
Recovered from the drawing itself: every pin on each net below is joined by a wire, a junction or a shared supply or ground symbol.
| Net | Connects |
|---|---|
| N1 | A1.A0, RV1.wiper |
| N2 | A1.D9, R1.1 |
| N3 | A1.5V, RV1.1 |
| GND | A1.GND, RV1.3, D1.K |
| N4 | R1.2, D1.A |
Outer pins to 5V and GND, middle pin (the wiper) to an analog input such as A0. analogRead(A0) then returns 0 to 1023.
analogRead returns 0 to 1023 (10 bits) but analogWrite takes 0 to 255 (8 bits). Dividing by 4 maps one range onto the other; map(value, 0, 1023, 0, 255) does the same.
Pins 3, 5, 6, 9, 10 and 11, marked with a ~ on the board.
Yes, with the pot's top end on 3.3 V instead of 5 V and a smaller LED resistor, about 100 Ω. The ESP32 reads 0 to 4095 by default because its ADC is 12-bit.
Open this circuit in the AI circuit diagram maker and ask for a change in plain English, edit a value, switch to IEC symbols, or export it as SVG, PNG, PDF, a KiCad project or a SPICE netlist. Opening the example and exporting it are free.
A GPIO pin switches a 5 V relay through a 470 Ω resistor and a 2N2222, with a flyback diode.
Open the diagram in ProtoFlow, the free AI PCB design app for Windows, macOS and Linux: pick real parts, lay out and route the board, simulate with SPICE and export Gerbers. Imports and exports KiCad, Altium and EAGLE.
Free to start. No card required.