Try Embedded

Measuring Voltages with a Multimeter

Three multimeters check an Uno's circuit: a pin switching between 0 V and 5 V, a voltage divider's middle, and an input that nothing drives.

Basic · Beginner

In a real product: Field service kit (Industrial): Technicians check a product's voltages with a multimeter.

A multimeter is the first tool to reach for when a circuit does not do what the code says. It shows what is really on a wire, not what the program meant to put there. This circuit has three meters, each with its COM probe on GND.

What you'll learn

  • Measuring a voltage: COM on GND, V on the point to check
  • What a voltage divider does: two equal resistors from 5 V to GND put half of it, 2.5 V, at their middle
  • What a floating input is, and why INPUT_PULLUP exists

How it works

  • Meter 1 is on pin 13. The sketch switches it every second, so the meter reads 5.00 V, then 0.00 V.
  • Meter 2 is on the middle of two 10 kΩ resistors in series from 5 V to GND. The current through both is the same, so each drops half the 5 V: the meter reads 2.50 V. Change one resistor and the middle moves: the voltage there is 5 V × R2 / (R1 + R2).
  • Meter 3 is on pin 7, an input with nothing connected. Nothing drives it, so the meter reads FLOAT. On a real board the pin picks up noise and digitalRead returns HIGH or LOW at random; the simulator reads it as 0, but the meter shows that nothing sets it.

Try this

  • Change pin 7's pinMode to INPUT_PULLUP and run it again: meter 3 now reads 5 V, and digitalRead gives 1 every time.
  • Make R2 20 kΩ (select it and change its value) and work out the new reading before you run it: 5 × 20 / 30 = 3.33 V.
  • Move meter 1's V probe to the 3.3V pin, then to GND.

sketch.ino

// Pin 13 switches every second for meter 1; pin 7 is an input left floating, for meter 3.
void setup() {
  Serial.begin(9600);
  pinMode(13, OUTPUT);
  pinMode(7, INPUT);
}

void loop() {
  digitalWrite(13, !digitalRead(13));
  Serial.print("pin 13 is ");
  Serial.print(digitalRead(13) ? "HIGH" : "LOW");
  Serial.print(", pin 7 reads ");
  Serial.println(digitalRead(7));
  delay(1000);
}

Lessons behind it