from machine import Pin, ADC, PWM
from utime import sleep, sleep_ms
sonido = PWM(Pin(36))
do = Pin(18, Pin.IN, Pin.PULL_UP)
re = Pin(17, Pin.IN, Pin.PULL_UP)
mi = Pin(16, Pin.IN, Pin.PULL_UP)
fa = Pin(15, Pin.IN, Pin.PULL_UP)
notas = [261, 293, 329, 349, 392, 440, 493, 523]
while True:
print(do.value(),re.value(),mi.value(),fa.value())
if do.value()==0:
sonido.freq(261)
sonido.duty(1023)
elif re.value()==0:
sonido.freq(293)
sonido.duty(1023)
elif mi.value()==0:
sonido.freq(329)
sonido.duty(1023)
elif fa.value()==0:
sonido.freq(349)
sonido.duty(1023)
else:
sonido.freq(20)
sonido.duty(0)