Skip to content

Instantly share code, notes, and snippets.

@benevpi
Created February 25, 2022 15:48
Show Gist options
  • Save benevpi/f4f5312307bf724cd0323425a774c304 to your computer and use it in GitHub Desktop.
Save benevpi/f4f5312307bf724cd0323425a774c304 to your computer and use it in GitHub Desktop.
test code for the PCB buttons
# Write your code here :-)
import time
import digitalio
import board
import touchio
on_off = True
led = digitalio.DigitalInOut(board.GP0)
led.direction = digitalio.Direction.OUTPUT
led2 = digitalio.DigitalInOut(board.GP18)
led2.direction = digitalio.Direction.OUTPUT
touch_pin = touchio.TouchIn(board.GP17 )
button = digitalio.DigitalInOut(board.GP16)
button.direction = digitalio.Direction.INPUT
button.pull = digitalio.Pull.UP
while True:
led.value = button.value
time.sleep(0.1) # the above line can cause a spike in the touch value and falsly trigger the below line
led2.value = touch_pin.value
time.sleep(0.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment