Handling inputs and outputs

Inputs and outputs on microcontrollers are either analog or digital.

Analog I/O

These APIs read or set the voltage of analog pins:

  • AnalogIn: read the voltage of an analog input pin.
  • AnalogOut: set the voltage of an analog output pin.

Digital I/O

You can control the digital pins individually or as a grouped value.

Individual control

  • DigitalIn: read a single digital input pin.
  • DigitalOut: write to a single digital output pin.
  • DigitalInOut: read and write to a single bidirectional digital pin.

Grouped control

  • Bus: flexible control of multiple pins:
    • BusIn: read multiple pins as a single value.
    • BusOut: write a single value to multiple pins.
    • BusInOut: read and write to multiple bidirectional pins.
  • Port: fast way to handle an underlying GPIO; this is less flexible than the bus because of the constraints the underlying GPIO ports impose:
    • PortIn: read multiple pins as a single value.
    • PortOut: write a single value to multiple pins.
    • PortInOut: read and write to multiple bidirectional pins.

InterruptIn

InterruptIn triggers an event when a digital input pin changes value.

PwmOut

PwmOut controls the frequency and mark to space ratio of a digital pulse wave (or train).