import machine
buzzer_pin = machine.Pin(0, machine.Pin.OUT)
led_pin = machine.Pin(1, machine.Pin.OUT)
slide_pot = machine.ADC(26)
def read_pot_value():
return slide_pot.read_u16()
def turn_on_buzzer():
buzzer_pin.on()
def turn_off_buzzer():
buzzer_pin.off()
def turn_on_green_led():
led_pin.on()
def turn_off_green_led():
led_pin.off()
while True:
pot_value = read_pot_value()
pot_percentage = (pot_value / 65535) * 100
if pot_percentage > 80:
turn_on_buzzer()
turn_off_green_led()
if pot_percentage < 80:
turn_off_buzzer()
turn_on_green_led()
else:
turn_off_buzzer()
turn_on_green_led()