10. Analogue Inputs, ADC & Voltage Dividers
Measure voltage and scale readings into engineering values.
Learning outcomes
- Explain 10-bit ADC resolution
- Wire a potentiometer as a divider
- Convert ADC counts to volts
- Use map and constrain appropriately
Parts and preparation
Uno, 10 k ohm potentiometer, breadboard, jumper wires and multimeter.
Before power: inspect wiring, confirm supply voltage and ensure all connected circuits share GND.
ADC conversion
On a 5 V Uno with the default reference, analogRead returns 0-1023 for approximately 0-5 V. One count is about 5 / 1023 = 4.89 mV.
Voltage divider
Two series resistances divide a supply. A potentiometer provides an adjustable ratio through its wiper.
Scaling
Voltage = raw * Vref / 1023.0. map performs integer linear scaling; constrain limits a value to a safe range.
Measurement uncertainty
USB 5 V is not an exact reference. Measure the actual 5 V rail when accuracy matters and average noisy readings.
Wiring and safe build sequence

- Pot outer leg -> 5 V
- Other outer leg -> GND
- Centre wiper -> A0
Worked sketch
Download .ino sketchconst byte sensorPin = A0;
void setup() {
Serial.begin(9600);
}
void loop() {
int raw = analogRead(sensorPin);
float voltage = raw * (5.0 / 1023.0);
int percent = map(raw, 0, 1023, 0, 100);
Serial.print("ADC=");
Serial.print(raw);
Serial.print(" V=");
Serial.print(voltage, 2);
Serial.print(" %=");
Serial.println(percent);
delay(200);
}How the code works
- 5.0 forces floating-point calculation.
- The ADC count and voltage should rise together as the wiper moves toward 5 V.
Test and record evidence
Practical evidence checklist
Common faults and checks
- A fixed reading suggests the wiper is not connected to A0.
- Erratic readings can indicate a missing GND or poor breadboard contact.
Check your understanding
Q1. How many codes does a 10-bit ADC have?
Show answer
1024 codes, numbered 0-1023.
Q2. Why use 5.0 instead of 5?
Show answer
To request floating-point division rather than integer arithmetic.