Created
February 25, 2022 15:48
-
-
Save benevpi/f4f5312307bf724cd0323425a774c304 to your computer and use it in GitHub Desktop.
test code for the PCB buttons
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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