From 86394d8b5fba985c27ddc764cff11fd428c2cd1b Mon Sep 17 00:00:00 2001 From: Shaun Setlock Date: Sat, 6 Nov 2021 16:54:38 -0400 Subject: [PATCH] Updating sample scripts to use final pin assignments. --- README.md | 13 ++++++++++++- pb/pb.py | 21 +++++++++++++++++---- relay/relay.py | 11 +++++++++-- 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 6277448..64a3512 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,14 @@ # garden -Python project for building an indoor garden with the Setlock ladies. \ No newline at end of file +Python project for building an indoor garden with the Setlock ladies. + +## BCM Pin Assignments + +| BCM Number | Device | Function | +|------------|--------|----------| +| 4 | Green Pushbutton | Sequence Start | +| 27 | Yellow Pushbutton | Lamp | +| 13 | Blue Pushbutton | Water Pump | +| 26 | Relay 1 | N.O. Pump | +| 20 | Relay 2 | *Unassigned* | +| 21 | Relay 3 | N.O. Lamp | \ No newline at end of file diff --git a/pb/pb.py b/pb/pb.py index e210382..013434d 100755 --- a/pb/pb.py +++ b/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: diff --git a/relay/relay.py b/relay/relay.py index 6496b0c..99c3de3 100644 --- a/relay/relay.py +++ b/relay/relay.py @@ -16,14 +16,21 @@ if __name__ == "__main__": # Setup the output pin; initialize OFF. GPIO.setup(RELAY1_PIN, GPIO.OUT) GPIO.output(RELAY1_PIN, False) + GPIO.setup(RELAY2_PIN, GPIO.OUT) + GPIO.output(RELAY2_PIN, False) + GPIO.setup(RELAY3_PIN, GPIO.OUT) + GPIO.output(RELAY3_PIN, False) + # Short toggle. i = 0 try: - time.sleep(1.0) + time.sleep(10.0) GPIO.output(RELAY1_PIN, True) - time.sleep(2.0) + GPIO.output(RELAY3_PIN, True) + time.sleep(60.0) GPIO.output(RELAY1_PIN, False) + GPIO.output(RELAY3_PIN, False) time.sleep(1.0) finally: