In simple electrical terms for our Raspberry Pi, when we drive a GPIO pin high, its voltage measures ~3.3 volts, and when we drive it low, it measures ~0 volts.
Let's observe this using a multimeter:
Different multimeters may have different connections and labeling than the multimeter illustrated here. Consult your multimeter's manual if you are unsure how to set it up for measuring voltage.
- Set your multimeter to its voltage setting and attach it to GPIO 21 and GND, as shown in the following diagram:
Figure 6.3 – Connecting a multimeter to a GPIO pin
- Run the following code, which you can find in the chapter06/digital_output_test.py file. You will notice that the meter toggles between about 0 volts and about 3.3 volts. I say about because nothing is ever really perfect or precise in electronics; there are always tolerances. Here's a synopsis of the code:
# ... truncated ...
GPIO_PIN = 21
pi = pigpio.pi()
pi.set_mode(GPIO_PIN, pigpio...