Datasheet
CircuitPython Digital In & Out
The first part of interfacing with hardware is being able to manage digital inputs and outputs. With Circuitpython it's
super easy!
This quick-start example shows how you can use one of the Circuit Playground Express buttons as an
input
to control
another digital
output
- the built in LED
Copy and paste the code block into code.py using your favorite text editor, and save the file, to run the demo
# CircuitPlaygroundExpress_DigitalIO
import time
import board
from digitalio import DigitalInOut, Direction, Pull
led = DigitalInOut(board.D13)
led.direction = Direction.OUTPUT
button = DigitalInOut(board.BUTTON_A)
button.direction = Direction.INPUT
button.pull = Pull.DOWN
while True:
if button.value: # button is pushed
led.value = True
else:
led.value = False
time.sleep(0.01)
© Adafruit Industries https://learn.adafruit.com/adafruit-circuit-playground-express Page 95 of 211










