Archived
1
0
This repository has been archived on 2025-04-27. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
garden/pb/pb.py
2021-10-18 20:22:07 -04:00

28 lines
538 B
Python
Executable File

#! env/bin/python3
import RPi.GPIO as GPIO
import time
if __name__ == "__main__":
# Setup for Hardware
PB_BCM = 6
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
# Use the internal pull-down.
GPIO.setup(PB_BCM, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
# Begin detected presses.
i = 0
try:
while True:
if GPIO.input(PB_BCM):
i += 1
print(f"Hi Gabby! Did you push the button? i = {i}")
time.sleep(0.1)
finally:
GPIO.cleanup()