Aide pour script python gpio led blink loop

bonjour Jai besoin d’aide pour terminer mon script
voici
je suis tous nouveau avec le python et je vient de m’acheter un asus tinker board (= raspberry)
bon je voudrai avoir une led (RBG) que je mettrais a l’intérieure qui changerais de couleur en appuyant sur un bouton
bon la partie couleur simple est fait et marche très bien. mais je voudrai aussi avoir une LOOP de couleur clignotante (exemple, rouge,blue,rouge,bleu ou blanc,off,blanc,off)

voici mon script

import ASUS.GPIO as GPIO
import time

GPIO.setwarnings(False)
GPIO.setmode(GPIO.ASUS)

RED = 167 # RED
BLUE = 164 # BLUE
GREEN = 166 # GREEN
BUTTON = 257 # BUTTON

GPIO.setup(RED,GPIO.OUT)# LEDPin
GPIO.setup(BLUE,GPIO.OUT)#LEDpin
GPIO.setup(GREEN,GPIO.OUT)#LEDpin
GPIO.setup(buttonPin, GPIO.IN, pull_up_down = GPIO.PUD_UP)# BUTTON

buttonPress = True
ledState = False
redState = False
blueState = False
greenState = False
purpleState = False
azurState = False
orangeState = False
whiteState = False
flashState = False

try:
while True:
buttonPress = GPIO.input(buttonPin)
if buttonPress == False and redState == False:
GPIO.output(RED, True) #red light
GPIO.output(BLUE, False)
GPIO.output(GREEN, False)
print « led red »
redState = True
ledState = True
time.sleep(0.5)
elif buttonPress == False and blueState == False:
GPIO.output(RED, False)
GPIO.output(BLUE, True)#blue light
GPIO.output(GREEN, False)
print « led blue »
blueState = True
time.sleep(0.5)
elif buttonPress == False and greenState == False:
GPIO.output(RED, False)
GPIO.output(BLUE, False)
GPIO.output(GREEN, True)#green light
print « led green »
greenState = True
time.sleep(0.5)
elif buttonPress == False and purpleState == False:
GPIO.output(RED, True)#purple light
GPIO.output(BLUE, True)
GPIO.output(GREEN, False)
print « led purple »
purpleState = True
time.sleep(0.5)
elif buttonPress == False and azurState == False:
GPIO.output(RED, False)#azur light
GPIO.output(BLUE, True)
GPIO.output(GREEN, True)
print « led azur »
azurState = True
time.sleep(0.5)
elif buttonPress == False and orangeState == False:
GPIO.output(RED, True)#orange light
GPIO.output(BLUE, False)
GPIO.output(GREEN, True)
print « led orange »
orangeState = True
time.sleep(0.5)
elif buttonPress == False and whiteState == False:
GPIO.output(RED, True)#white light
GPIO.output(BLUE, True)
GPIO.output(GREEN, True)
print « led white »
whiteState = True
time.sleep(0.5)
elif buttonPress == False and flashState == False:
print « led flash patern » #----------- debut du loop
GPIO.output(RED,True)#red light
GPIO.output(BLUE,False)
GPIO.output(GREEN,False)
time.sleep(0.05)
GPIO.output(RED,False)#close led
GPIO.output(BLUE,False)
GPIO.output(GREEN,False)
time.sleep(0.05)
GPIO.output(RED,True)#red light
GPIO.output(BLUE,False)
GPIO.output(GREEN,False)
time.sleep(0.05)
GPIO.output(RED,False)#close led
GPIO.output(BLUE,False)
GPIO.output(GREEN,False)
time.sleep(0.05)
GPIO.output(RED,False)#blue light
GPIO.output(BLUE,True)
GPIO.output(GREEN,False)
time.sleep(0.05)
GPIO.output(RED,False)#close led
GPIO.output(BLUE,False)
GPIO.output(GREEN,False)
time.sleep(0.05)
GPIO.output(RED,False)#blue light
GPIO.output(BLUE,True)
GPIO.output(GREEN,False)
time.sleep(0.05)
GPIO.output(RED,False)#close led
GPIO.output(BLUE,False)
GPIO.output(GREEN,False)
time.sleep(0.05)
GPIO.output(RED,False)#green light
GPIO.output(BLUE,False)
GPIO.output(GREEN,True)
time.sleep(0.05)
GPIO.output(RED,False)#close led
GPIO.output(BLUE,False)
GPIO.output(GREEN,False)
time.sleep(0.05)
GPIO.output(RED,False)#green light
GPIO.output(BLUE,False)
GPIO.output(GREEN,True)
time.sleep(0.05)
GPIO.output(RED,False)#close led
GPIO.output(BLUE,False)
GPIO.output(GREEN,False)
time.sleep(0.05)
GPIO.output(RED,True)#puple light
GPIO.output(BLUE,True)
GPIO.output(GREEN,False)
time.sleep(0.05)
GPIO.output(RED,False)#close led
GPIO.output(BLUE,False)
GPIO.output(GREEN,False)
time.sleep(0.05)
GPIO.output(RED,True)#puple light
GPIO.output(BLUE,True)
GPIO.output(GREEN,False)
time.sleep(0.05)
GPIO.output(RED,False)#close led
GPIO.output(BLUE,False)
GPIO.output(GREEN,False)
time.sleep(0.05)
GPIO.output(RED,False)#azur light
GPIO.output(BLUE,True)
GPIO.output(GREEN,True)
time.sleep(0.05)
GPIO.output(RED,False)#close led
GPIO.output(BLUE,False)
GPIO.output(GREEN,False)
time.sleep(0.05)
GPIO.output(RED,False)#azur light
GPIO.output(BLUE,True)
GPIO.output(GREEN,True)
time.sleep(0.05)
GPIO.output(RED,False)#close led
GPIO.output(BLUE,False)
GPIO.output(GREEN,False)
time.sleep(0.05)
GPIO.output(RED,True)#orange light
GPIO.output(BLUE,False)
GPIO.output(GREEN,True)
time.sleep(0.05)
GPIO.output(RED,False)#close led
GPIO.output(BLUE,False)
GPIO.output(GREEN,False)
time.sleep(0.05)
GPIO.output(RED,True)#orange light
GPIO.output(BLUE,False)
GPIO.output(GREEN,True)
time.sleep(0.05)
GPIO.output(RED,False)#close led
GPIO.output(BLUE,False)
GPIO.output(GREEN,False)
time.sleep(0.05)
GPIO.output(RED,True)#white light
GPIO.output(BLUE,True)
GPIO.output(GREEN,True)
time.sleep(0.05)
GPIO.output(RED,False)#close led
GPIO.output(BLUE,False)
GPIO.output(GREEN,False)
time.sleep(0.05)
GPIO.output(RED,True)#white light
GPIO.output(BLUE,True)
GPIO.output(GREEN,True)
time.sleep(0.05)
flashState = True #--------------- fin de loop
#—loop—
elif buttonPress == False and ledState == True:
GPIO.output(RED, False)#close led
GPIO.output(BLUE, False)
GPIO.output(GREEN, False)
print « led off »
ledState = False
redState = False
blueState = False
greenState = False
purpleState= False
azurState = False
orangeState= False
whiteState = False
flashState = False
time.sleep(0.5)

finally:
GPIO.output(RED, False)
GPIO.output(BLUE, False)
GPIO.output(GREEN, False)
GPIO.cleanup()

j’aimerais savoir comment looper le flashState que Jai créé merci

Salut et bienvenu

Alors, dans un premier temps je ne pourrais pas t’aider car je ne fais aucune manipulation du GPIO ,

mais, je fais du python et la du code coller comme sa sans indentation sa m’étonnerai que quelqu’un te corrige , car c’est pas agréable a lire .

Donc soit tu héberges ailleurs ton code et tu nous donnes le lien , soit tu utilise les balisse Comment copier du code python dans ce forum? - Python - Le Forum français de la Raspberry Pi - Raspberry Pi FR (Raspbian France)

cordialement