from machine import Pin
from time import sleep
# led腳位號碼串列
led_numbers = [23, 22, 21, 19, 18, 5, 4, 26, 25, 33, 32, 27]
# 生成led腳位物件串列
led_pins = [Pin(n, Pin.OUT) for n in led_numbers]
while True:
# 依串列點亮led
for pin in led_pins:
pin.value(1)
sleep(0.1)
# 依串列熄掉led
for pin in led_pins:
pin.value(0)
sleep(0.1)
# led1=Pin(23, Pin.OUT)
# led2=Pin(22, Pin.OUT)
# led3=Pin(21, Pin.OUT)
# led4=Pin(19, Pin.OUT)
# led5=Pin(18, Pin.OUT)
# led6=Pin(5, Pin.OUT)
# led7=Pin(4, Pin.OUT)
# led8=Pin(26, Pin.OUT)
# led9=Pin(25, Pin.OUT)
# led10=Pin(33, Pin.OUT)
# led11=Pin(32, Pin.OUT)
# led12=Pin(27, Pin.OUT)
# led1.value(1)
# sleep(0.1)
# led2.value(1)
# sleep(0.1)
# led3.value(1)
# sleep(0.1)
# led4.value(1)
# sleep(0.1)
# led5.value(1)
# sleep(0.1)
# led6.value(1)
# sleep(0.1)
# led7.value(1)
# sleep(0.1)
# led8.value(1)
# sleep(0.1)
# led9.value(1)
# sleep(0.1)
# led10.value(1)
# sleep(0.1)
# led11.value(1)
# sleep(0.1)
# led12.value(1)
# sleep(0.1)
# led1.value(0)
# sleep(0.1)
# led2.value(0)
# sleep(0.1)
# led3.value(0)
# sleep(0.1)
# led4.value(0)
# sleep(0.1)
# led5.value(0)
# sleep(0.1)
# led6.value(0)
# sleep(0.1)
# led7.value(0)
# sleep(0.1)
# led8.value(0)
# sleep(0.1)
# led9.value(0)
# sleep(0.1)
# led10.value(0)
# sleep(0.1)
# led11.value(0)
# sleep(0.1)
# led12.value(0)
# sleep(0.1)