from machine import Pin, ADC
from neopixel import NeoPixel
from time import sleep_ms
from math import log 


pAnalogico = Pin(33)
sensor = ADC(pAnalogico)
pNeoPixel = Pin(23, Pin.OUT)
np = NeoPixel(pNeoPixel, 16)

while True:
    valor = sensor.read_u16()
    
    t = 1/(log(1/((65535/valor)-1))/3950 + 1/298.15) -273.15
    
    
    #print (f'Temperatura:{t:.2f}')

    if t < 25:
        for posicao in range(len(np)):
            np[posicao] = (0, 0, 255)
    elif t >= 25 and t <= 40:
        for posicao in range(len(np)):
            np[posicao] = (0, 255, 0)
    else:
        for posicao in range(len(np)):
            np[posicao] = (255, 0, 0)
    np.write()
    #sleep_ms(1000)