Digital refers to signals which are either on or off (high or low, one or zero). This contrasts with analog signals which have a range of values.
Digital inputs are read as being HIGH or LOW in the Arduino code. There are no intermediate values.
The datasheet specifies voltage levels:
- A certain level below which a signal is considered LOW
- Another level, above which a signal is considered HIGH
- There is normally an in-between level where the signal is undefined (it might be HIGH or LOW randomly).
As an example, on the Atmega328P, operating at 5 volts supply, the levels for most pins are:
- -0.5 V to 1.5 V - considered LOW
- Above 1.5 and below 3 V - undefined
- 3 V to 5.5 V - considered HIGH
Digital outputs are written as HIGH or LOW in the Arduino code. There are no intermediate values.
The driver transistors in the processor attempt to bring the corresponding output pin to 0 V for LOW and VCC for HIGH (where VCC is the supply voltage for the chip, typically 3.3 V or 5 V).
As an example, the datasheet for the Atmega328P specifies that (at an ambient temperature of 85°C, driving 20 mA, and running at 5 V) the output pin should be:
- A maximum of 0.9 V when driven LOW
- A minimum of 4.2 V when driven HIGH
Contrast the above to the analog inputs on the Arduino which use an ADC (Analog to Digital Converter) to read a range of values on an input pin, and return a number corresponding to where that voltage lies in the range 0 to the analog reference voltage.
See also: analogread