You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.3 KiB

2 years ago
2 years ago
2 years ago
  1. #!/usr/bin/python
  2. import sys #reconocer lo que hay en la terminal
  3. import time
  4. LED_PATH = "/sys/class/leds/beaglebone:green:usr3"
  5. def writeLED(fileName, value, path=LED_PATH):
  6. """
  7. Ayuda de la rutina
  8. writeLED(fileName, value, path=LED_PATH)
  9. """
  10. fo = open(path + fileName, "w")
  11. fo.write(value)
  12. fo.close()
  13. return
  14. def removeTrigger():
  15. writeLED("/trigger","none")
  16. return
  17. print("Starting App")
  18. #removeTrigger()
  19. #writeLED("/brightness", "1")
  20. #print("LED3 on")
  21. #print("Finish App")
  22. if len(sys.argv)!=2:
  23. print("Incorrect number of arguments")
  24. sys.exit(2)
  25. if sys.argv[1] == "on":
  26. print("LED on")
  27. removeTrigger()
  28. writeLED("/brightness", "1")
  29. print("LED3 on")
  30. elif sys.argv[1] == "off":
  31. print("LED off")
  32. removeTrigger()
  33. writeLED("/brightness", "0")
  34. print("LED3 off")
  35. elif sys.argv[1]=="b":
  36. print("blinking")
  37. removeTrigger()
  38. writeLED("/trigger", "timer")
  39. writeLED("/delay_on","500")
  40. writeLED("/delay_off","500")
  41. else:
  42. print("Wrong command!!!")
  43. print("Wrong command!!!")
  44. print("To turn on the LED please type: ./led.py on")
  45. print("To turn off the LED please type: ./led.py off")
  46. print("To make the LED blink please type: sudo ./led.py b")
  47. print("Script done")