from machine import Pin,ADC,PWM
import time
red = Pin(13, Pin.OUT)
blue = Pin(14, Pin.OUT)
green = Pin(15, Pin.OUT)
pot = ADC(27)
buzzer=PWM(Pin(15))
while True:
value = pot.read_u16()
temperature = (value / 65535) * 100
red.off()
green.off()
blue.off()
if temperature > 60:
blue.on()
buzzer.freq(2500)
buzzer.duty_u16(30000)
elif temperature > 30:
green.on()
buzzer.duty_u16(0)
else:
red.on()
buzzer.duty_u16(0)
time.sleep(0.5)
Loading
pi-pico-w
pi-pico-w