33 lines
744 B
Python
33 lines
744 B
Python
# Toggles gpio to turn grow lights on/off
|
|
import requests
|
|
import time
|
|
import subprocess
|
|
|
|
gpio_lights = "4"
|
|
|
|
def toggle_lights(state):
|
|
|
|
if state == 'on':
|
|
print('on')
|
|
subprocess.run(["gpio", "mode", gpio_lights, "out"])
|
|
subprocess.run(["gpio", "write", gpio_lights, "1"])
|
|
else:
|
|
print('off')
|
|
subprocess.run(["gpio", "write", gpio_lights, "0"])
|
|
subprocess.run(["gpio", "mode", gpio_lights, "in"])
|
|
|
|
|
|
def turn_on_lights():
|
|
print('Turning lights on')
|
|
toggle_lights('on')
|
|
|
|
def turn_off_lights():
|
|
print('Turning lights off')
|
|
toggle_lights('off')
|
|
|
|
print('Starting up')
|
|
#Just to check lights are off
|
|
#turn_off_lights()
|
|
#print('Lights are off')
|
|
turn_on_lights()
|
|
print('Lights are on') |