Procházet zdrojové kódy

Script erweitert

master
Alex Volkmann před 6 roky
rodič
revize
13fa31c721
1 změnil soubory, kde provedl 95 přidání a 124 odebrání
  1. +95
    -124
      gpio_test.py

+ 95
- 124
gpio_test.py Zobrazit soubor

@@ -1,134 +1,105 @@
import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)

GPIO.setup(14, GPIO.OUT)
GPIO.setup(15, GPIO.OUT)
GPIO.setup(18, GPIO.OUT)
GPIO.setup(23, GPIO.OUT)
GPIO.setup(24, GPIO.OUT)
GPIO.setup(25, GPIO.OUT)
GPIO.setup(8, GPIO.OUT)
GPIO.setup(7, GPIO.OUT)
GPIO.setup(12, GPIO.OUT)
GPIO.setup(16, GPIO.OUT)
GPIO.setup(20, GPIO.OUT)
GPIO.setup(21, GPIO.OUT)
GPIO.setup(2, GPIO.OUT)
GPIO.setup(3, GPIO.OUT)
GPIO.setup(4, GPIO.OUT)
GPIO.setup(17, GPIO.OUT)
GPIO.setup(27, GPIO.OUT)
GPIO.setup(22, GPIO.OUT)
GPIO.setup(10, GPIO.OUT)
GPIO.setup(9, GPIO.OUT)
GPIO.setup(11, GPIO.OUT)
GPIO.setup(5, GPIO.OUT)
GPIO.setup(6, GPIO.OUT)
GPIO.setup(13, GPIO.OUT)

for i in range(1):
GPIO.output(14, GPIO.HIGH)
time.sleep(1)
GPIO.output(15, GPIO.HIGH)
time.sleep(1)
GPIO.output(18, GPIO.HIGH)
time.sleep(1)
GPIO.output(23, GPIO.HIGH)
time.sleep(1)
GPIO.output(24, GPIO.HIGH)
time.sleep(1)
GPIO.output(25, GPIO.HIGH)
time.sleep(1)
GPIO.output(8, GPIO.HIGH)
time.sleep(1)
GPIO.output(7, GPIO.HIGH)
time.sleep(1)
GPIO.output(12, GPIO.HIGH)
time.sleep(1)
GPIO.output(16, GPIO.HIGH)
time.sleep(1)
GPIO.output(20, GPIO.HIGH)
time.sleep(1)
GPIO.output(21, GPIO.HIGH)
time.sleep(1)
GPIO.output(2, GPIO.HIGH)
time.sleep(1)
GPIO.output(3, GPIO.HIGH)
time.sleep(1)
GPIO.output(4, GPIO.HIGH)
time.sleep(1)
GPIO.output(17, GPIO.HIGH)
time.sleep(1)
GPIO.output(27, GPIO.HIGH)
time.sleep(1)
GPIO.output(22, GPIO.HIGH)
time.sleep(1)
GPIO.output(10, GPIO.HIGH)
time.sleep(1)
GPIO.output(9, GPIO.HIGH)
time.sleep(1)
GPIO.output(11, GPIO.HIGH)
time.sleep(1)
GPIO.output(5, GPIO.HIGH)
time.sleep(1)
GPIO.output(6, GPIO.HIGH)
time.sleep(1)
GPIO.output(13, GPIO.HIGH)
time.sleep(1)

GPIO.output(14, GPIO.LOW)
time.sleep(1)
GPIO.output(15, GPIO.LOW)
time.sleep(1)
GPIO.output(18, GPIO.LOW)
time.sleep(1)
GPIO.output(23, GPIO.LOW)
time.sleep(1)
GPIO.output(24, GPIO.LOW)
time.sleep(1)
GPIO.output(25, GPIO.LOW)
time.sleep(1)
GPIO.output(8, GPIO.LOW)
time.sleep(1)
GPIO.output(7, GPIO.LOW)
time.sleep(1)
GPIO.output(12, GPIO.LOW)
time.sleep(1)
GPIO.output(16, GPIO.LOW)
time.sleep(1)
GPIO.output(20, GPIO.LOW)
time.sleep(1)
GPIO.output(21, GPIO.LOW)
time.sleep(1)
GPIO.output(2, GPIO.LOW)
time.sleep(1)
GPIO.output(3, GPIO.LOW)
time.sleep(1)
GPIO.output(4, GPIO.LOW)
time.sleep(1)
GPIO.output(17, GPIO.LOW)
time.sleep(1)
GPIO.output(27, GPIO.LOW)
time.sleep(1)
GPIO.output(22, GPIO.LOW)
time.sleep(1)
GPIO.output(10, GPIO.LOW)
time.sleep(1)
GPIO.output(9, GPIO.LOW)
time.sleep(1)
GPIO.output(11, GPIO.LOW)
time.sleep(1)
GPIO.output(5, GPIO.LOW)
time.sleep(1)
GPIO.output(6, GPIO.LOW)
time.sleep(1)
GPIO.output(13, GPIO.LOW)

def TurnAround(timeout):

for i in range(5):

GPIO.output(4, GPIO.LOW)
GPIO.output(14, GPIO.HIGH)
time.sleep(timeout)
GPIO.output(15, GPIO.HIGH)
GPIO.output(14, GPIO.LOW)
time.sleep(timeout)
GPIO.output(18, GPIO.HIGH)
GPIO.output(15, GPIO.LOW)
time.sleep(timeout)
GPIO.output(23, GPIO.HIGH)
GPIO.output(18, GPIO.LOW)
time.sleep(timeout)
GPIO.output(24, GPIO.HIGH)
GPIO.output(23, GPIO.LOW)
time.sleep(timeout)
GPIO.output(25, GPIO.HIGH)
GPIO.output(24, GPIO.LOW)
time.sleep(timeout)
GPIO.output(8, GPIO.HIGH)
GPIO.output(25, GPIO.LOW)
time.sleep(timeout)
GPIO.output(7, GPIO.HIGH)
GPIO.output(8, GPIO.LOW)
time.sleep(timeout)
GPIO.output(21, GPIO.HIGH)
GPIO.output(7, GPIO.LOW)
time.sleep(timeout)
GPIO.output(13, GPIO.HIGH)
GPIO.output(21, GPIO.LOW)
time.sleep(timeout)
GPIO.output(6, GPIO.HIGH)
GPIO.output(13, GPIO.LOW)
time.sleep(timeout)
GPIO.output(5, GPIO.HIGH)
GPIO.output(6, GPIO.LOW)
time.sleep(timeout)
GPIO.output(11, GPIO.HIGH)
GPIO.output(5, GPIO.LOW)
time.sleep(timeout)
GPIO.output(10, GPIO.HIGH)
GPIO.output(11, GPIO.LOW)
time.sleep(timeout)
GPIO.output(27, GPIO.HIGH)
GPIO.output(10, GPIO.LOW)
time.sleep(timeout)
GPIO.output(3, GPIO.HIGH)
GPIO.output(27, GPIO.LOW)
time.sleep(timeout)
GPIO.output(2, GPIO.HIGH)
GPIO.output(3, GPIO.LOW)
time.sleep(timeout)
GPIO.output(4, GPIO.HIGH)
GPIO.output(2, GPIO.LOW)
time.sleep(timeout)




def AllPortsOnOff(gpiolist, timeout):

# set all ports
for port in gpiolist:
GPIO.output(port, GPIO.HIGH)
time.sleep(timeout)

# reset all ports
for port in gpiolist:
GPIO.output(port, GPIO.LOW)
time.sleep(timeout)
TurnAround

def init(gpiolist):
print("init ports")
GPIO.setmode(GPIO.BCM)

print("set ports to output")
# set port to output
for port in gpiolist:
GPIO.setup(port, GPIO.OUT)

print("reset all gpio ports")
# reset all gpio ports
for port in gpiolist:
GPIO.output(port, GPIO.LOW)

def main():

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]

init(gpiolist)
AllPortsOnOff(gpiolist, 0.1)

TurnAround(0.1)
GPIO.cleanup()

if __name__ == "__main__":
main()

Načítá se…
Zrušit
Uložit