Created
February 28, 2014 11:48
-
-
Save Lysander/9269755 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RPi. GPIO as GPIO | |
import time | |
import random | |
SLEEPING_TIME = 0.05 | |
PORTS = (7, 11, 12, 13, 15, 16) | |
SEQUENCES = [ | |
( | |
# Programm 1 | |
( | |
(7, GPIO.HIGH) | |
), | |
( | |
(11, GPIO.HIGH) | |
), | |
( | |
(7, GPIO.LOW) | |
) | |
), | |
( | |
# Programm 3 | |
( | |
(7, GPIO.HIGH), | |
(15, GPIO.HIGH), | |
), | |
( | |
(11, GPIO.HIGH) | |
(12, GPIO.HIGH) | |
) | |
) | |
] | |
def init_ports(ports): | |
GPIO.setwarnings(False) | |
GPIO.setmode(GPIO.BOARD) | |
for port in ports: | |
GPIO.setup(port, GPIO.OUT) | |
def run_sequence(sequence, sleeping_time=SLEEPING_TIME): | |
for section in sequence: | |
for command in section: | |
GPIO.output(*command) | |
time.sleep(sleeping_time) | |
def main(): | |
init_ports(PORTS) | |
random.shuffle(SEQUENCES) | |
try: | |
run_sequence(SEQUENCES[0]) | |
except KeyboardInterrupt: | |
print: "Fin" | |
GPIO.cleanup() | |
if __name == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment