from machine import Pin,ADC,PWM
from time import sleep
from dht import DHT22
led1=Pin(0,Pin.OUT)
led2=Pin(2,Pin.OUT)
led3=Pin(6,Pin.OUT)
pir=Pin(27,Pin.IN)
pot=ADC(26)
dht=DHT22(22)
buz=PWM(28)
tim=ADC(4)
bot=Pin(12,Pin.IN,Pin.PULL_UP)
def loren (args):
leit=input('faça sua escolha?:')
if leit=="potenciometro":
pott=pot.read_u16
led1.on()
led2.off()
led3.off()
sleep(2)
buz.freq(326)
buz.duty_u16(100)
elif leit=="DHT":
try:
sensor.measure()
temp=dht.temperature()
umid=dht.humidity()
sleep(2)
except:
print('erro')
print(temp,umid)
led1.off()
led2.on()
led3.off()
buz.freq(784)
buz.duty_u16(100)
elif resp == "I":
coisa=tim.read_16()
tensao=coisa*3.3/65535
tt=27-(tensao-0.706)/(0.001721)
print(coisa)
print(tensao)
print(tt)
led1.off()
led2.off()
led3.on()
sleep(2)
else:
print('tudo errado')
bot.irq(handler=loren,trigger=Pin.IRQ_RESING)
pir.irq(handler=loren,trigger=Pin.IRQ_RESING)
while True:
led1.off()
led2.off()
led3.off()
buz.duty_u16(0)
sleep(2)