digitalio — Basic digital pin support

The digitalio module contains classes to provide access to basic digital IO.

Libraries

All classes change hardware state and should be deinitialized when they are no longer needed. To do so, either call deinit() or use a context manager.

For example:

import digitalio
from board import *

with digitalio.DigitalInOut(D13) as pin:
  print(pin.value)

This example will initialize the the device, read value and then deinit() the hardware.

Here is blinky:

import digitalio
from board import *
import time

with digitalio.DigitalInOut(D13) as led:
  led.switch_to_output()
  while True:
    led.value = True
    time.sleep(0.1)
    led.value = False
    time.sleep(0.1)