from machine import Pin, PWM
import asyncio
led_4 = PWM(Pin(4), freq = 2000)
led_4.duty_u16(0)
led_5 = Pin(5, Pin.OUT)
controle = ''
async def pwm():
for i in range(2):
for duty in range(0, 100, 1):
brilho = int(duty * 655.35)
led_4.duty_u16(brilho)
await asyncio.sleep_ms(30)
led_4.duty_u16(0)
async def piscar():
for i in range(16):
led_5.on()
await asyncio.sleep_ms(250)
led_5.off()
await asyncio.sleep_ms(250)
async def gerenciador():
global controle
flag = True
while flag:
controle = input('Digite a, b ou c: ')
if controle == 'a':
await pwm()
elif controle == 'b':
await piscar()
elif controle == 'c':
await asyncio.gather(pwm(), piscar())
elif controle == 'd':
flag = False
print('Programa encerrado pelo usuário')
async def principal():
await gerenciador()
asyncio.run(principal())