from machine import Pin
import uasyncio
from utime import sleep
# description of LEDs connected to the board
led1 = Pin(4, Pin.OUT) # green LED
led2 = Pin(5, Pin.OUT) # red LED
led3 = Pin(6, Pin.OUT) # yellow LED
async def blink(led, period):
while True:
led.on()
await uasyncio.sleep(period) # period in s
led.off()
await uasyncio.sleep(period)
async def main():
uasyncio.create_task(blink(led1, 0.16)) # green LED
uasyncio.create_task(blink(led2, 0.33)) # red LED
uasyncio.create_task(blink(led3, 0.33)) # orange LED
# function main() does not contain endless loop
# if will stop after 10s
await uasyncio.sleep_ms(10000)
uasyncio.run(main())