from machine import Timer,Pin
from time import sleep as wait
led_3 = Pin(21, Pin.OUT)
led_2 = Pin(19, Pin.OUT)
led_1 = Pin(18, Pin.OUT)
led_0 = Pin(5, Pin.OUT)
count = 0 #led counter
def handler_0(tim0):
global count
leds = [led_0,led_1,led_2,led_3] # list of LEDs
LED = leds[count] #temporary led handler
LED.value(1)
count +=1 #shift to the next LED
#go to previous LED and set its value to 0
wait(2) #ON time and OFF time of the active LED is 2s
LED = leds[count - 1]
LED.value(0)
#reset the counter when last LED is reached
if count == 4:
count = 0
tim0 = Timer(0)
tim0.init(period=1000,mode=Timer.PERIODIC,callback=handler_0)
from machine import Timer,Pin
from time import sleep as wait
led_3 = Pin(21, Pin.OUT)
led_2 = Pin(19, Pin.OUT)
led_1 = Pin(18, Pin.OUT)
led_0 = Pin(5, Pin.OUT)
count = 0 #led counter
def handler_0(tim0):
global count
leds = [led_0,led_1,led_2,led_3] # list of LEDs
LED = leds[count] #temporary led handler
LED.value(1)
count +=1 #shift to the next LED
#go to previous LED and set its value to 0
wait(2) #ON time and OFF time of the active LED is 2s
LED = leds[count - 1]
LED.value(0)
#reset the counter when last LED is reached
if count == 4:
count = 0
tim0 = Timer(0)
tim0.init(period=1000,mode=Timer.PERIODIC,callback=handler_0)