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.

52 lines
1.1 KiB

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. while True:
  39. writeLED("/brightness", "1")
  40. time.sleep(0.5)
  41. writeLED("/brightness","0")
  42. time.sleep(0.5)
  43. else:
  44. print("Wrong command!!!")
  45. print("Script done")