Archived
1
0

Updating sample scripts to use final pin assignments.

This commit is contained in:
Shaun Setlock
2021-11-06 16:54:38 -04:00
parent f7aa608ae7
commit 86394d8b5f
3 changed files with 38 additions and 7 deletions

View File

@@ -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: