Archived
1
0

Pushing some work on automatic mode.

This commit is contained in:
Shaun Setlock
2021-11-12 13:55:45 -05:00
parent ec287ae047
commit a0ea4c743d
4 changed files with 82 additions and 1 deletions

43
automatic/input.py Normal file
View File

@@ -0,0 +1,43 @@
#! env/bin/python3
import RPi.GPIO as GPIO
import time
from datetime import datetime
def get_pin_input():
# Pin Assignments
PB1_BCM = 4 # Green
PB2_BCM = 27 # Yellow
PB3_BCM = 13 # Blue
RELAY1_PIN = 26 # Water Pump
RELAY2_PIN = 20 # Unassigned
RELAY3_PIN = 21 # Lamp
# Setup the Inputs to use the internal pull-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)
# Setup the Outputs.
GPIO.setup(RELAY1_PIN, GPIO.OUT)
GPIO.setup(RELAY2_PIN, GPIO.OUT)
GPIO.setup(RELAY3_PIN, GPIO.OUT)
# Get current time.
now = datetime.now()
hour = now.hour
minute = now.minute
# Define alias variables for input devices.
inputs = {
'green_button' : GPIO.input(PB1_BCM),
'yellow_button' : GPIO.input(PB2_BCM),
'blue_button' : GPIO.input(PB3_BCM),
'pump' : GPIO.input(RELAY1_PIN),
'lamp' : GPIO.input(RELAY3_PIN),
'hour' : hour,
'minute' : minute,
}
return inputs