Browse Source

first commit

master
Demo User 2 years ago
commit
ffa8a68b32
1 changed files with 52 additions and 0 deletions
  1. +52
    -0
      led.py

+ 52
- 0
led.py View File

@ -0,0 +1,52 @@
#!/usr/bin/python
import sys #reconocer lo que hay en la terminal
import time
LED_PATH = "/sys/class/leds/beaglebone:green:usr3"
def writeLED(fileName, value, path=LED_PATH):
"""
Ayuda de la rutina
writeLED(fileName, value, path=LED_PATH)
"""
fo = open(path + fileName, "w")
fo.write(value)
fo.close()
return
def removeTrigger():
writeLED("/trigger","none")
return
print("Starting App")
#removeTrigger()
#writeLED("/brightness", "1")
#print("LED3 on")
#print("Finish App")
if len(sys.argv)!=2:
print("Incorrect number of arguments")
sys.exit(2)
if sys.argv[1] == "on":
print("LED on")
removeTrigger()
writeLED("/brightness", "1")
print("LED3 on")
elif sys.argv[1] == "off":
print("LED off")
removeTrigger()
writeLED("/brightness", "0")
print("LED3 off")
elif sys.argv[1]=="b":
print("blinking")
removeTrigger()
while True:
writeLED("/brightness", "1")
time.sleep(0.5)
writeLED("/brightness","0")
time.sleep(0.5)
else:
print("Wrong command!!!")
print("Script done")

Loading…
Cancel
Save