User manual

47
Le programme
ledmuster.py permet de faire clignoter les LED de différentes façons.
# -*- coding: utf-8 -*-
import RPi.GPIO as GPIO
import time
import random
GPIO.setmode(GPIO.BCM)
LED = [4,18,23,24]
for i in LED:
GPIO.setup(i, GPIO.OUT, initial=0)
z = len(LED); w = 5; t = 0.2
print ("Choix de l'effet lumineux"); print ("1 – chenillard cyclique")
print ("2 – chenillard aller-retour"); print ("3 – montées et descentes")
print ("4 – Tous clignotent simultanément"); print ("5 – tous clignotent
aléatoirement")
print ("Ctrl+C arrête le programme")
try:
while True:
e = raw_input ("Veuillez choisir le motif : ")
if e == "1":
for i in range(w):
for j in range(z):
GPIO.output(LED[j], True); time.sleep(t)
GPIO.output(LED[j], False)
elif e == "2":
for i in range(w):
for j in range(z):
GPIO.output(LED[j], True); time.sleep(t)
GPIO.output(LED[j], False)
for j in range(z-1, -1, -1):
GPIO.output(LED[j], True); time.sleep(t)
GPIO.output(LED[j], False)
elif e == "3":
for i in range(w):
for j in range(z):
GPIO.output(LED[j], True); time.sleep(t)
time.sleep(2*t)
for j in range(z-1, -1, -1):
GPIO.output(LED[j], False)
time.sleep(t)
time.sleep(2*t)
elif e == "4":
for i in range(w):
for j in range(z):
GPIO.output(LED[j], True)
time.sleep(2*t)
for j in range(z):
GPIO.output(LED[j], False)
time.sleep(t)
elif e == "5":