Analog inputs and outputs are important for interacting with many types of sensors and other devices. This guide will explore what an analog signal is and how it differs from digital signals, how to read analog signals, and how to output analog signals with CircuitPython.
Analog signals are different from digital signals in that they can be any voltage and can vary continuously and smoothly between voltages. An analog signal is like a dimmer switch on a light, whereas a digital signal is like a simple on/off switch.
Digital signals only can ever have two states, they are either are on (high logic level voltage like 3.3V) or off (low logic level voltage like 0V / ground).
By contrast, analog signals can be any voltage in-between on and off, such as 1.8V or 0.001V or 2.98V and so on.
Analog signals are continuous values which means they can be an infinite number of different voltages. Think of analog signals like a floating point or fractional number, they can smoothly transiting to any in-between value like 1.8V, 1.81V, 1.801V, 1.8001V, 1.80001V and so forth to infinity.
Many devices use analog signals, in particular sensors typically output an analog signal or voltage that varies based on something being sensed like light, heat, humidity, etc. Some examples of sensors with analog outputs:
- Photocells (light sensitive resistors)
- Temperature sensors
- Force-sensitive resistors
- Flex sensors
- Thermistor (temperature sensitive resistor)
- Ultraviolet light sensor
- Light sensors
- Distance sensor
- Anemometer (wind speed sensor)
- Resistive touch screen
- Ultrasonic distance sensor
- Liquid level sensor
- Potentiometer (variable resistor)
The are also some devices that can be controlled by analog signals or varying voltages:
And there are some devices that are controlled by a special type of analog-like signal called a pulse-width modulated, or PWM, signal. You’ll learn more about PWM signals at the end of this guide, but some devices that can be driven by a PWM signal are: