planktoscope/scripts/light.py

27 lines
467 B
Python
Raw Normal View History

2019-12-13 19:49:19 +01:00
#!/usr/bin/env python
2019-12-13 21:28:39 +01:00
#Turn on using this command line :
#python3.7 path/to/file/light.py on
#Turn off using this command line :
#python3.7 path/to/file/light.py off
2019-12-13 19:49:19 +01:00
import RPi.GPIO as GPIO
import sys
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
2019-12-13 19:53:52 +01:00
GPIO.setup(21,GPIO.OUT)
2019-12-13 19:49:19 +01:00
2019-12-13 23:13:23 +01:00
state = str(sys.argv[1])
2019-12-13 19:49:19 +01:00
def light(state):
2019-12-14 07:02:00 +01:00
if state == "true":
2019-12-13 19:49:19 +01:00
GPIO.output(21,GPIO.HIGH)
2019-12-14 07:02:00 +01:00
if state == "false":
2019-12-13 19:49:19 +01:00
GPIO.output(21,GPIO.LOW)
light(state)