Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """CircuitPython Essentials Digital In Out example"""
- import time
- import board
- from digitalio import DigitalInOut, Direction, Pull
- # LED setup.
- led = DigitalInOut(board.LED)
- led.direction = Direction.OUTPUT
- switch = DigitalInOut(board.D5) # For Feather M0 Express, Feather M4 Express
- switch.direction = Direction.INPUT
- switch.pull = Pull.UP
- while True:
- # We could also do "led.value = not switch.value"!
- if switch.value:
- led.value = False
- else:
- led.value = True
- time.sleep(0.01) # debounce delay
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement