10 kΩ Resistor Voltage Divider with Arduino Uno: Wiring and Code
EDITOR REVIEW — INCOMPLETE MEDIA: Cover and circuit illustrations must be uploaded and inserted before publication. The scheduled run cannot upload local files because network access is blocked. Code is documentation-reviewed, not compiled or hardware-tested.
Build a simple resistor voltage divider and read its output on an Arduino Uno. With two equal resistors, you can turn the board’s 5 V supply into a signal near half that voltage and see the result in Serial Monitor.
Level: beginner · Build time: about 20 minutes after IDE setup · Platform: classic Arduino Uno R3
In this tutorial
- How a divider works
- Parts and connections
- Build and upload
- Complete code
- Expected results and troubleshooting
How the circuit works
R1 connects 5 V to the measurement junction. R2 connects that junction to GND. With very little current drawn by the measurement input, Vout = Vin × R2 / (R1 + R2). Two 10 kΩ resistors therefore give about half the supply voltage. Connect the junction to A0.
At 5 V, the series current is 5 ÷ 20,000 = 0.25 mA. Each resistor dissipates approximately 0.625 mW, comfortably below its ¼ W rating. A divider supplies a measurement signal; it is not a substitute for a power regulator.
Components required
| Component / purchase link | Specification | Needed |
|---|---|---|
| Arduino Uno R3 | Classic 5 V ATmega328P model | 1 |
| 10 kΩ resistors | ¼ W, ±5%; sold as a pack of 10 | 2 |
| Solderless breadboard | 840 tie points | 1 |
| Male-to-male jumper wires | 20 cm; sold as a pack of 40 | 3 |
| USB A–B data cable | UNO R3 USB Type-B connector | 1 |
Needed quantities refer to this build, not the seller’s pack size.
Circuit schematic
Editor: insert the prepared circuit schematic here after media upload is available.
UNO 5V ── R1 (10 kΩ) ──┬── R2 (10 kΩ) ── UNO GND
└── UNO A0Visual breadboard wiring
Editor: insert the prepared breadboard diagram here after media upload is available.
| Connection | Breadboard example |
|---|---|
| 5V → R1 top | 5V to a1; R1 from b1 to b4 |
| R1/R2 junction → A0 | A0 to d4; R2 from c4 to c7 |
| R2 bottom → GND | GND to a7 |
On a standard breadboard, a–e are connected within each numbered row. Row 4 joins R1, R2 and A0. Board drawings are symbolic: locate 5V, A0 and GND using the printed pin labels.
Assembly and Arduino IDE setup
- Unplug USB before assembling. Insert the two resistors in the rows above, keeping their leads separate except at the intended shared junction.
- Connect the three jumper wires. Check that neither resistor is bypassed by a wire or breadboard strip.
- Install Arduino IDE from arduino.cc. Select Arduino Uno under Arduino AVR Boards and select the board’s port.
- Connect the USB A–B data cable. Paste the program below into a new sketch.
- Click Verify, then Upload. Open Serial Monitor at 9600 baud.
No additional libraries or online account is needed. Use only the Uno’s own 5V and GND for this experiment. Do not connect mains, battery packs or unknown external voltages to A0. This is a 5 V Uno R3 tutorial; it is not wiring guidance for 3.3 V boards.
Complete program
// Anu Electronics: two 10k resistors in series from UNO 5V to GND.
// Connect their junction to A0. For classic 5V Arduino Uno R3 only.
const byte INPUT_PIN = A0;
const float ASSUMED_REFERENCE_V = 5.0;
void setup() {
analogReference(DEFAULT);
Serial.begin(9600);
}
void loop() {
int raw = analogRead(INPUT_PIN);
float estimatedVoltage = raw * (ASSUMED_REFERENCE_V / 1023.0);
Serial.print("ADC: ");
Serial.print(raw);
Serial.print(" Estimated voltage: ");
Serial.println(estimatedVoltage, 3);
delay(500);
}
Code explanation
analogRead(A0) returns the classic Uno’s 10-bit reading. The code displays both the raw count and a voltage estimate, using 5.0 V as an assumed reference. delay(500) spaces the output by roughly half a second. The default reference follows the board supply, so the raw reading is a ratio; it does not independently measure the actual USB supply voltage.
Expected output
ADC: 511 Estimated voltage: 2.498 ADC: 512 Estimated voltage: 2.502
These are illustrative values, not recorded hardware measurements. Equal nominal resistors should give a value near mid-scale. With opposing ±5% resistor tolerances, the theoretical ratio can range from 0.475 to 0.525, so approximately 486–537 counts is possible before adding ADC error and noise. Do not assume one exact reading is required.
Troubleshooting
- Reading near zero: check the 5V connection, R1 and the A0 junction.
- Reading near 1023: inspect the GND connection and R2; ensure A0 is not directly wired to 5V.
- Large random changes: A0 may be floating. Check the shared junction and breadboard contacts.
- Unreadable text: select 9600 baud in Serial Monitor.
- Incorrect voltage estimate: measure the board supply with a suitable meter and use that measured value for the conversion, or compare raw ADC ratios.
Frequently asked questions
Do resistors have a direction?
These carbon-film resistors are not polarised. Either end can connect to the supply or junction.
Can I power a module from the divider?
No. A load changes the divider ratio and output voltage. Use a suitable regulated supply for powered modules.
Can I use this as a precision voltmeter?
This is a teaching circuit. Accuracy depends on resistor tolerance, reference voltage, ADC error and loading. A measurement instrument needs an appropriate design and calibration.
Try next
Swap R1 and R2 and compare readings. With nominally equal values, expect little change; differences help illustrate resistor tolerance. Unplug USB before changing connections.
Build it with 10 kΩ resistors and an Arduino Uno R3 from Anu Electronics.