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/automatic/input.py
2021-11-12 13:55:45 -05:00

43 lines
1.1 KiB
Python

#! 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