# 3-Key Piano import time from machine import Pin, PWM # Construct PWM object, with LED on Pin(25) Spkr = PWM(Pin(18)) B0 = Pin(20, Pin.IN, Pin.PULL_UP) B1 = Pin(21, Pin.IN, Pin.PULL_UP) B2 = Pin(22, Pin.IN, Pin.PULL_UP) while(1): if(B0.value() == 0): Spkr.freq(220) Spkr.duty_u16(32768) while(B0.value() == 0): pass if(B1.value() == 0): Spkr.freq(250) Spkr.duty_u16(32768) while(B1.value() == 0): pass if(B2.value() == 0): Spkr.freq(280) Spkr.duty_u16(32768) while(B2.value() == 0): pass pwm.duty_u16(0)