from machine import Pin,ADC
from time import sleep
temp=ADC(Pin(33))
temp.atten(ADC.ATTN_11DB)
temp.width(ADC.WIDTH_12BIT)
r=Pin(12,Pin.OUT)
g=Pin(14,Pin.OUT)
b=Pin(27,Pin.OUT)
buzzer=Pin(15,Pin.OUT)
raw = temp.read()
temperature_a = raw * (3.3 / 4095)
while(1):
print(raw)
print(temperature_a)
voltage_ref=27
if temperature_a > 27:
buzzer.value(1)
else:
buzzer.value(0)
if 0 <= temperature_a <= 25:
r.off()
g.on()
b.off()
elif 26 <= temperature_a <= 35:
r.on()
g.off()
b.off()
else:
r.off()
g.off()
b.on()
Loading
ds18b20
ds18b20