from machine import Pin, ADC
from neopixel import NeoPixel
from time import sleep_ms
from math import log
sensor = ADC (Pin(33), atten = ADC.ATTN_11DB)
n = NeoPixel(Pin(21,Pin.OUT), 16)
botao = Pin(26,Pin.IN,Pin.PULL_DOWN)
#i = 0
def elo(valor):
if valor == 0:
return 0
negocio = log(1/(65535/valor-1))
bagulho = negocio/3950 + 1/298.15
temp = 1/bagulho - 273.15
return temp
while True:
if botao.value() == 1:
x = sensor.read_u16()
temp = elo(x)
print(temp)
if temp <= 10:
for i in range(16):
n[i] = (0, 129, 255)
n.write()
elif temp > 10 and temp <= 25:
for i in range(16):
n[i] = (0,128,0)
n.write()
elif temp > 25 and temp <= 35:
for i in range(16):
n[i] = (255,0,0)
n.write()
else:
for i in range(16):
n[i] = (0,0,0)
n.write()Loading
esp32-devkit-c-v4
esp32-devkit-c-v4