planktoscope/scripts/light.py

27 lines
463 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
state = int(sys.argv[1])
def light(state):
if state == "on":
GPIO.output(21,GPIO.HIGH)
if state == "off":
GPIO.output(21,GPIO.LOW)
light(state)