import uasyncio as asyncio
from machine import Pin
led1 = Pin(2, Pin.OUT)
led2 = Pin(3, Pin.OUT)
cnt = 0
async def task1():
while True:
print("Task 1 executing...")
led1.toggle()
await asyncio.sleep(2)
print(cnt)
if cnt % 5 == 0:
print("Hello UTeM")
async def task2():
global cnt
while True:
print("Task 2 executing...")
led2.toggle()
cnt += 1
await asyncio.sleep(1)
# Create event loop
loop = asyncio.get_event_loop()
# Schedule tasks
loop.create_task(task1())
loop.create_task(task2())
# Run event loop
loop.run_forever()