from machine import Pin
from machine import PWM
import time
from random import randint
# Set our pin 2 to PWM
pwm = PWM(Pin(2))
btn1 = Pin(23, Pin.IN, Pin.PULL_UP)
btn2 = Pin(22, Pin.IN, Pin.PULL_UP)
led = Pin(15,Pin.OUT)
pwm.freq(1)
def switch_buzz(freq):
if(freq == False):
pwm.freq(1)
else:
pwm.freq(freq)
while(True):
if(btn1.value() == 0):
switch_buzz(440)
led.value(0)
elif(btn2.value() == 0):
switch_buzz(300)
led.value(1)
else:
switch_buzz(False)