Phyton script zum steuern der selbst gebauten pdu.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

gpio_test.py 2.2 KiB

il y a 6 ans
il y a 6 ans
il y a 6 ans
il y a 6 ans
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import RPi.GPIO as GPIO
  2. import time
  3. def TurnAround(timeout):
  4. for i in range(5):
  5. GPIO.output(4, GPIO.LOW)
  6. GPIO.output(14, GPIO.HIGH)
  7. time.sleep(timeout)
  8. GPIO.output(15, GPIO.HIGH)
  9. GPIO.output(14, GPIO.LOW)
  10. time.sleep(timeout)
  11. GPIO.output(18, GPIO.HIGH)
  12. GPIO.output(15, GPIO.LOW)
  13. time.sleep(timeout)
  14. GPIO.output(23, GPIO.HIGH)
  15. GPIO.output(18, GPIO.LOW)
  16. time.sleep(timeout)
  17. GPIO.output(24, GPIO.HIGH)
  18. GPIO.output(23, GPIO.LOW)
  19. time.sleep(timeout)
  20. GPIO.output(25, GPIO.HIGH)
  21. GPIO.output(24, GPIO.LOW)
  22. time.sleep(timeout)
  23. GPIO.output(8, GPIO.HIGH)
  24. GPIO.output(25, GPIO.LOW)
  25. time.sleep(timeout)
  26. GPIO.output(7, GPIO.HIGH)
  27. GPIO.output(8, GPIO.LOW)
  28. time.sleep(timeout)
  29. GPIO.output(21, GPIO.HIGH)
  30. GPIO.output(7, GPIO.LOW)
  31. time.sleep(timeout)
  32. GPIO.output(13, GPIO.HIGH)
  33. GPIO.output(21, GPIO.LOW)
  34. time.sleep(timeout)
  35. GPIO.output(6, GPIO.HIGH)
  36. GPIO.output(13, GPIO.LOW)
  37. time.sleep(timeout)
  38. GPIO.output(5, GPIO.HIGH)
  39. GPIO.output(6, GPIO.LOW)
  40. time.sleep(timeout)
  41. GPIO.output(11, GPIO.HIGH)
  42. GPIO.output(5, GPIO.LOW)
  43. time.sleep(timeout)
  44. GPIO.output(10, GPIO.HIGH)
  45. GPIO.output(11, GPIO.LOW)
  46. time.sleep(timeout)
  47. GPIO.output(27, GPIO.HIGH)
  48. GPIO.output(10, GPIO.LOW)
  49. time.sleep(timeout)
  50. GPIO.output(3, GPIO.HIGH)
  51. GPIO.output(27, GPIO.LOW)
  52. time.sleep(timeout)
  53. GPIO.output(2, GPIO.HIGH)
  54. GPIO.output(3, GPIO.LOW)
  55. time.sleep(timeout)
  56. GPIO.output(4, GPIO.HIGH)
  57. GPIO.output(2, GPIO.LOW)
  58. time.sleep(timeout)
  59. def AllPortsOnOff(gpiolist, timeout):
  60. # set all ports
  61. for port in gpiolist:
  62. GPIO.output(port, GPIO.HIGH)
  63. time.sleep(timeout)
  64. # reset all ports
  65. for port in gpiolist:
  66. GPIO.output(port, GPIO.LOW)
  67. time.sleep(timeout)
  68. TurnAround
  69. def init(gpiolist):
  70. print("init ports")
  71. GPIO.setmode(GPIO.BCM)
  72. print("set ports to output")
  73. # set port to output
  74. for port in gpiolist:
  75. GPIO.setup(port, GPIO.OUT)
  76. print("reset all gpio ports")
  77. # reset all gpio ports
  78. for port in gpiolist:
  79. GPIO.output(port, GPIO.LOW)
  80. def main():
  81. gpiolist = [14, 15, 18, 23, 24, 25, 8, 7, 4, 17, 22, 9, 12, 16, 20, 21, 2, 3, 27, 10, 11, 5, 6, 13]
  82. init(gpiolist)
  83. AllPortsOnOff(gpiolist, 0.1)
  84. TurnAround(0.1)
  85. GPIO.cleanup()
  86. if __name__ == "__main__":
  87. main()