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

@@ -1,3 +1,14 @@
# garden # garden
Python project for building an indoor garden with the Setlock ladies. 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 |

View File

@@ -6,21 +6,34 @@ import time
if __name__ == "__main__": if __name__ == "__main__":
# Setup for Hardware # Setup for Hardware
PB_BCM = 6 PB1_BCM = 4 # Green
PB2_BCM = 27 # Yellow
PB3_BCM = 13 # Blue
GPIO.setmode(GPIO.BCM) GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False) GPIO.setwarnings(False)
# Use the internal pull-down. # 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. # Begin detected presses.
i = 0 i = 0
try: try:
while True: while True:
if GPIO.input(PB_BCM): # Green
if GPIO.input(PB1_BCM):
i += 1 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) time.sleep(0.1)
finally: finally:

View File

@@ -16,14 +16,21 @@ if __name__ == "__main__":
# Setup the output pin; initialize OFF. # Setup the output pin; initialize OFF.
GPIO.setup(RELAY1_PIN, GPIO.OUT) GPIO.setup(RELAY1_PIN, GPIO.OUT)
GPIO.output(RELAY1_PIN, False) 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. # Short toggle.
i = 0 i = 0
try: try:
time.sleep(1.0) time.sleep(10.0)
GPIO.output(RELAY1_PIN, True) 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(RELAY1_PIN, False)
GPIO.output(RELAY3_PIN, False)
time.sleep(1.0) time.sleep(1.0)
finally: finally: