Advertisement
lucasmcg

Circuit Python Digital IO M4

Sep 28th, 2021
839
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. """CircuitPython Essentials Digital In Out example"""
  2. import time
  3. import board
  4. from digitalio import DigitalInOut, Direction, Pull
  5.  
  6. # LED setup.
  7. led = DigitalInOut(board.LED)
  8. led.direction = Direction.OUTPUT
  9. switch = DigitalInOut(board.D5) # For Feather M0 Express, Feather M4 Express
  10. switch.direction = Direction.INPUT
  11. switch.pull = Pull.UP
  12.  
  13. while True:
  14.     # We could also do "led.value = not switch.value"!
  15.     if switch.value:
  16.         led.value = False
  17.     else:
  18.         led.value = True
  19.     time.sleep(0.01) # debounce delay
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement