from machine import Pin
from time import sleep
led0 = Pin(0, Pin.OUT)
led1 = Pin(1, Pin.OUT)
led2 = Pin(2, Pin.OUT)
led3 = Pin(3, Pin.OUT)
led4 = Pin(4, Pin.OUT)
led5 = Pin(5, Pin.OUT)
led6 = Pin(6, Pin.OUT)
led7 = Pin(7, Pin.OUT)
led8 = Pin(8, Pin.OUT)
led9 = Pin(9, Pin.OUT)
def sequence():
led0.value(1)
sleep(1)
led0.value(0)
led1.value(1)
sleep(1)
led1.value(0)
led2.value(1)
sleep(1)
led2.value(0)
led3.value(1)
sleep(1)
led3.value(0)
led4.value(1)
sleep(1)
led4.value(0)
led5.value(1)
sleep(1)
led5.value(0)
led6.value(1)
sleep(1)
led6.value(0)
led7.value(1)
sleep(1)
led7.value(0)
led8.value(1)
sleep(1)
led8.value(0)
led9.value(1)
sleep(1)
led9.value(0)
def reverse():
led9.value(1)
sleep(1)
led9.value(0)
led8.value(1)
sleep(1)
led8.value(0)
led7.value(1)
sleep(1)
led7.value(0)
led6.value(1)
sleep(1)
led6.value(0)
led5.value(1)
sleep(1)
led5.value(0)
led4.value(1)
sleep(1)
led4.value(0)
led3.value(1)
sleep(1)
led3.value(0)
led2.value(1)
sleep(1)
led2.value(0)
led1.value(1)
sleep(1)
led1.value(0)
led0.value(1)
sleep(1)
led0.value(0)
def middle():
led4.value(1)
led5.value(1)
sleep(1)
led4.value(0)
led5.value(0)
led3.value(1)
led6.value(1)
sleep(1)
led3.value(0)
led6.value(0)
led2.value(1)
led7.value(1)
sleep(1)
led2.value(0)
led7.value(0)
led1.value(1)
led8.value(1)
sleep(1)
led1.value(0)
led8.value(0)
led0.value(1)
led9.value(1)
sleep(1)
led0.value(0)
led9.value(0)
def alternating():
# Odd LEDs on
led1.value(1)
led3.value(1)
led5.value(1)
led7.value(1)
led9.value(1)
# Even LEDs off
led0.value(0)
led2.value(0)
led4.value(0)
led6.value(0)
led8.value(0)
sleep(1)
# Odd LEDs off
led1.value(0)
led3.value(0)
led5.value(0)
led7.value(0)
led9.value(0)
# Even LEDs on
led0.value(1)
led2.value(1)
led4.value(1)
led6.value(1)
led8.value(1)
sleep(1)
def ripple():
led0.value(1)
sleep(1)
led0.value(0)
led1.value(1)
sleep(1)
led1.value(0)
led2.value(1)
sleep(1)
led2.value(0)
led3.value(1)
sleep(1)
led3.value(0)
led4.value(1)
sleep(1)
led4.value(0)
led5.value(1)
sleep(1)
led5.value(0)
led6.value(1)
sleep(1)
led6.value(0)
led7.value(1)
sleep(1)
led7.value(0)
led8.value(1)
sleep(1)
led8.value(0)
led9.value(1)
sleep(1)
led9.value(0)
# Ripple Backwards
led8.value(1)
sleep(1)
led8.value(0)
led7.value(1)
sleep(1)
led7.value(0)
led6.value(1)
sleep(1)
led6.value(0)
led5.value(1)
sleep(1)
led5.value(0)
led4.value(1)
sleep(1)
led4.value(0)
led3.value(1)
sleep(1)
led3.value(0)
led2.value(1)
sleep(1)
led2.value(0)
led1.value(1)
sleep(1)
led1.value(0)
led0.value(1)
sleep(1)
led0.value(0)
def goandback():
led0.value(1)
sleep(1)
led0.value(0)
led1.value(1)
sleep(1)
led1.value(0)
led2.value(1)
sleep(1)
led2.value(0)
led3.value(1)
sleep(1)
led3.value(0)
led4.value(1)
sleep(1)
led4.value(0)
led5.value(1)
sleep(1)
led5.value(0)
led6.value(1)
sleep(1)
led6.value(0)
led7.value(1)
sleep(1)
led7.value(0)
led8.value(1)
sleep(1)
led8.value(0)
led9.value(1)
sleep(1)
led9.value(0)
led8.value(1)
sleep(1)
led8.value(0)
led7.value(1)
sleep(1)
led7.value(0)
led6.value(1)
sleep(1)
led6.value(0)
led5.value(1)
sleep(1)
led5.value(0)
led4.value(1)
sleep(1)
led4.value(0)
led3.value(1)
sleep(1)
led3.value(0)
led2.value(1)
sleep(1)
led2.value(0)
led1.value(1)
sleep(1)
led1.value(0)
led0.value(1)
sleep(1)
led0.value(0)
def blink_all():
led0.value(1)
led1.value(1)
led2.value(1)
led3.value(1)
led4.value(1)
led5.value(1)
led6.value(1)
led7.value(1)
led8.value(1)
led9.value(1)
sleep(1)
led0.value(0)
led1.value(0)
led2.value(0)
led3.value(0)
led4.value(0)
led5.value(0)
led6.value(0)
led7.value(0)
led8.value(0)
led9.value(0)
sleep(1)
while True:
sequence()
sleep(1)
reverse()
sleep(1)
middle()
sleep(1)
alternating()
sleep(1)
ripple()
sleep(1)
goandback()
sleep(1)
blink_all()
sleep(1)