Knowledge Base
Fundamentals

Introduction To IO

5min

Lead In

All interaction with a Microcontroller is performed using I/O, or inputs and outputs. IO may, in its simplest form be a single PIN which is configured as either an input or an output. They are generally grouped into two types

  • Digital, where the input/output value is either a 1 or 0, high or low. No specialized signal conversion is usually required for a number value of the I/O to be obtained
  • Analog, where the input or output voltage represents a value and that value is converted into a digital or numerical value for it to be useful as either an input or an output

Digital IO

Digital IO exists between two states, either high or low represented by a binary 1 or 0. When configured as an input, the signal changes between these two states signaling to the micro that an input has been received. The microcontroller is aware of the change in one of two ways. The input is read at a regular interval or an interrupt signals to the MCU that a change has taken place.

When configured as an output, the MCU then sets or clears the output. The term set refers to when it is 1 and clear refers to when it is zero.

Caution must be exercised when working with IO because the logical versus the physical implementation can have consequences that cause injury. For further details please see the section Working with Digital IO.

The code programmed into the device will determine when the output is activated, why, and for how long.

Analog IO

For most microcontrollers, analog IO is an input. A simple variable resistor can be your signal source, and the microcontroller then reads that changing value converting it into a numerical value.

For the input voltage to be read and converted into a numerical value, an Analog Digital Converter is required. Many microcontrollers have this as an internal peripheral which makes it easier to use. However, depending on the requirement, an external ADC may be interfaced with the microcontroller as well.

When the microcontroller is required to perform the reverse, a Digital to Analog conversion takes place and a Digital to Analog Converter is required. The resolution of the accuracy of the DAC is indicated by the number of bits it can process to produce the output. The same applies to the DAC, in that more microcontrollers now have the peripheral available internally. However, depending on the requirements, an external DAC may be interfaced with the microcontroller as well. External DAC may introduce high-performance, high-resolution capability to an application.

Ensure to check on the device's datasheet whether one has been included. The acronym DAC is often used.

The topic of analogs is a very in-depth and multifaceted discussion. Please see the section Working with Analogs.

๏ปฟ