Updating sample scripts to use final pin assignments.
This commit is contained in:
21
pb/pb.py
21
pb/pb.py
@@ -6,21 +6,34 @@ import time
|
||||
if __name__ == "__main__":
|
||||
|
||||
# Setup for Hardware
|
||||
PB_BCM = 6
|
||||
PB1_BCM = 4 # Green
|
||||
PB2_BCM = 27 # Yellow
|
||||
PB3_BCM = 13 # Blue
|
||||
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
GPIO.setwarnings(False)
|
||||
|
||||
# Use the internal pull-down.
|
||||
GPIO.setup(PB_BCM, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
|
||||
GPIO.setup(PB1_BCM, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
|
||||
GPIO.setup(PB2_BCM, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
|
||||
GPIO.setup(PB3_BCM, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
|
||||
|
||||
# Begin detected presses.
|
||||
i = 0
|
||||
try:
|
||||
while True:
|
||||
if GPIO.input(PB_BCM):
|
||||
# Green
|
||||
if GPIO.input(PB1_BCM):
|
||||
i += 1
|
||||
print(f"Hi Gabby! Did you push the button? i = {i}")
|
||||
print(f"Hi Gabby! Did you push the GREEN button? i = {i}")
|
||||
# Yellow
|
||||
if GPIO.input(PB2_BCM):
|
||||
i += 1
|
||||
print(f"Hi Gabby! Did you push the YELLOW button? i = {i}")
|
||||
# Blue
|
||||
if GPIO.input(PB3_BCM):
|
||||
i += 1
|
||||
print(f"Hi Gabby! Did you push the BLUE button? i = {i}")
|
||||
time.sleep(0.1)
|
||||
|
||||
finally:
|
||||
|
||||
Reference in New Issue
Block a user