from machine import Pin
from utime import sleep
RED = Pin(15, Pin.OUT)
YEL = Pin(18, Pin.OUT)
GRE = Pin(19, Pin.OUT)
BUTT = Pin(12, Pin.IN)
leds = [GRE, RED, YEL, RED]
current_led = 0
eter = 0
while True:
if BUTT.value() == 1:
current_led = 1;
for i, led in enumerate(leds):
if i == current_led:
led.value(1);
sleep(3);
current_led= (current_led + 1) % len(leds)
for i, led in enumerate(leds):
if i == current_led:
led.value(1);
sleep(2);
current_led= (current_led + 2) % len(leds)
for i, led in enumerate(leds):
if i == current_led:
led.value(1);
else:
led.value(0)
sleep(3);
for i, led in enumerate(leds):
if i == current_led:
led.value(1)
sleep(0.5)
led.value(0)
sleep(0.5)
led.value(1)
sleep(0.5)
led.value(0)
sleep(0.5)
led.value(1)
sleep(0.5)
led.value(0)
sleep(0.5)
led.value(1)
sleep(0.5)
led.value(0)
sleep(0.5)
else:
led.value(0)
current_led= (current_led + 2) % len(leds)
for i, led in enumerate(leds):
if i == current_led:
led.value(1);
else:
led.value(0)
sleep(2);
current_led= (current_led + 1) % len(leds)
for i, led in enumerate(leds):
if i == current_led:
led.value(1);
else:
led.value(0)
sleep(2);