diff --git a/pb/pb.py b/pb/pb.py index 388ee21..c38f5b2 100755 --- a/pb/pb.py +++ b/pb/pb.py @@ -18,7 +18,7 @@ if __name__ == "__main__": i = 0 try: while True: - if not GPIO.input(PB_PIN): + if GPIO.input(PB_PIN): i += 1 print(f"Hi Gabby! Did you push the button? i = {i}") time.sleep(0.1) diff --git a/relay/relay.py b/relay/relay.py new file mode 100644 index 0000000..6496b0c --- /dev/null +++ b/relay/relay.py @@ -0,0 +1,30 @@ +#! env/bin/python3 + +import RPi.GPIO as GPIO +import time + +if __name__ == "__main__": + + # Setup for Hardware + RELAY1_PIN = 26 + RELAY2_PIN = 20 + RELAY3_PIN = 21 + + GPIO.setmode(GPIO.BCM) + GPIO.setwarnings(False) + + # Setup the output pin; initialize OFF. + GPIO.setup(RELAY1_PIN, GPIO.OUT) + GPIO.output(RELAY1_PIN, False) + + # Short toggle. + i = 0 + try: + time.sleep(1.0) + GPIO.output(RELAY1_PIN, True) + time.sleep(2.0) + GPIO.output(RELAY1_PIN, False) + time.sleep(1.0) + + finally: + GPIO.cleanup() \ No newline at end of file