Potentiometer → analogRead() → LEDs
A pot is a voltage divider whose R1/R2 split changes as you turn the knob. Drag the knob (or use the slider) and watch the voltage, the 10-bit reading and the LEDs respond.
← fully anticlockwise (5 V) · fully clockwise (0 V) →
Rtot5 kΩ
R1 / R2
I = 5 V / 5 kΩ1 mA
Vout = I × R2
readVal = analogRead(A1)Vout = (5./1023.)*readVal