Single_Output.py, runs clean, linted, CP and python3 ready
import time
-import RPi.GPIO as GPIO
-GPIO.setmode(GPIO.BCM)
+import board
+from digitalio import DigitalInOut, Direction
-padPin = 23
-GPIO.setup(padPin, GPIO.IN)
+pad_pin = board.D23
+pad = DigitalInOut(pad_pin)
+pad.direction = Direction.INPUT
-alreadyPressed = False
+already_pressed = False
while True:
- padPressed = GPIO.input(padPin)
- if padPressed and not alreadyPressed:
- print "pressed"
+ if pad.value and not already_pressed:
+ print("pressed")
- alreadyPressed = padPressed
+ already_pressed = pad.value
time.sleep(0.1)
