from machine import Pin, ADC
from time import sleep
import dht
ldr = ADC(Pin(16))
ldr.atten(ADC.ATTN_11DB)
dh = dht.DHT22(Pin(15))
led = Pin(18, Pin.OUT)
lightest = 2000
tempest = 30
while True:
light = ldr.read()
dh.measure()
temp = dh.temperature()
if light < lightest:
led.value(1)
else:
led.value(0)
if temp > tempest:
print("high temperature!")
else:
print("low temperature")
sleep(1)