The Orange LED on the Sensorian board can be used in Python by manipulating its GPIO pin. The following example shows how to blink the LED in Python.
import RPi.GPIO as GPIO
import time
P0 = 12 # LED pin
"""Setups the pins in BCM mode
:param none:
:returns none :
"""
def Init():
GPIO.setwarnings(False) # suppress GPIO used message
GPIO.setmode(GPIO.BOARD) # use BCM pin numbers
GPIO.setup(P0, GPIO.OUT) # set LED pin as output
"""Turns on the LED on port P0
:param none:
:returns none :
"""
def LEDon():
GPIO.output(P0, GPIO.HIGH)
"""Turns off the LED on port P0
:param none:
:returns none :
"""
def LEDoff():
GPIO.output(P0, GPIO.LOW)
"""Sets the LED state as HIGH or LOW
:param state: state of the LED, can be 1 for HIGH or 0 for LOW.
:returns none :
"""
def SetLED(state):
if state:
LEDon()
else:
LEDoff()
# if not used as a module (standalone), run this test program
if __name__ == "__main__":
Init()
try:
while(True):
LEDoff()
time.sleep(0.5)
LEDon()
time.sleep(0.5)
except KeyboardInterrupt:
print("Clean exit on CTRL-C")
GPIO.cleanup()
__author__ = "Dhimiter Qendri"
__copyright__ = "Copyright Sensorian 2015"