from neopixel import NeoPixel
from machine import Pin, ADC
from time import sleep_ms
from equacao import convT
# Importação
n = NeoPixel(Pin(23,Pin.OUT),3)
sensor = ADC(Pin(33), atten = ADC.ATTN_11DB)
botao = Pin(25, Pin.IN, Pin.PULL_DOWN)
# Variáveis
while True:
if botao.value() == 1:
temp = sensor.read_u16() # Ler a tensão do ADC e converte-lá em inteiro, entre 0 e 65535
t = convT (temp)
if t >= 25:
n [0] = (255, 0, 0)
n [1] = (255, 0, 0)
n [2] = (255, 0, 0)
#print ("Água quente")
sleep_ms (150)
print (t)
elif t >= 20:
n [0] = (0, 255, 0)
n [1] = (0, 255, 0)
n [2] = (0, 255, 0)
#print ("Água morna")
sleep_ms (150)
print (t)
else:
n [0] = (0, 0, 255)
n [1] = (0, 0, 255)
n [2] = (0, 0, 255)
#print ("Água fria")
sleep_ms (150)
print (t)
else:
n [0] = (0, 0, 0)
n [1] = (0, 0, 0)
n [2] = (0, 0, 0)
print ("Desligado")
sleep_ms (150)
n.write()