This lesson covers the key differences between analog and digital output. You’ll be able to explain the key differences and how these outputs are represented in the Arduino.
HIGH
and LOW
states of the Arduino function digitalRead()
represent.In previous projects, you’ve used digital output, but that’s not the only type of output. Arduino also supports analog output. Let’s look at the differences between digital and analog.
Digital output is binary, which means that it has two states — ON or OFF. These states correspond to the HIGH
and LOW
commands sent by the Arduino function digitalWrite()
.
If the voltage is flowing then the pin is ON. If the voltage isn’t flowing, then the pin is OFF. The HIGH
state on an Arduino pin means that the pin is receiving voltage (typically 5V), and the LOW
state is when the pin is receiving 0V.
In the Blink example, the LED turned ON when it received voltage (when it was sent a HIGH
state) and then turned OFF when it didn’t have voltage (when it was sent a LOW
state).
Analog output isn’t binary. Instead, it supports a range of output between ON and OFF. The difference is best shown using a light switch:
The light switch has two states: on and off. This results in two states: lights are on or lights are off. What happens if you want a switch that could control the brightness of a light and have a range of light? In order to do this, you need to use analog output.
If a typical light switch represents digital output, then a dimmer switch represents analog output:
Analog output provides more control and flexibility because you’re able to output a range of values instead of ON or OFF. The key point to remember is that analog is a range and digital is either HIGH (ON) or LOW (OFF).
The next lesson is a deeper dive into more of the specifics of how the Arduino handles analog output.