from machine import Pin, PWM, DAC
from time import sleep
led = PWM(Pin(23),freq=800)
buzzer = PWM(Pin(22),freq=1000)
push = Pin(12,Pin.IN,Pin.PULL_UP)
def sonido(x):
led.duty(x)
buzzer.freq(200 + x * 20)
buzzer.duty(500)
lista = [0, 100, 300, 500, 700, 500, 300, 100, 0]
n=0
i=0
while(1):
if push.value()==0:
sleep(0.02)
n=n+1
if n > 8:
n=0
while push.value()==0:
sleep(0.2)
sonido(lista[n])
sleep(0.1)