import dht
from machine import Pin, PWM
from neopixel import NeoPixel
from servo import Servo
import time
from time import sleep
import _thread
def servo_temp():
servo = PWM(Pin(15), freq=50, duty=0)
sense = dht.DHT22(Pin(4))
while True:
sense.measure()
temp = int(sense.temperature())
min = -10
max = 40
if temp >= 0 and temp <= 30:
Servo(servo, temp * 5)
elif temp >= 31:
Servo(servo, 150)
else:
Servo(servo, 30)
def prehod_barv():
ln = 16
pixel = NeoPixel(Pin(25), 16)
while True:
barva = [0,255,0]
for i in range(ln):
pixel[i] = barva
pixel.write()
barva[0] += 255//ln
barva[1] -= 255//ln
sleep(0.1)
for i in range(ln-1,0,-1):
pixel[i] = (0,0,0)
pixel.write()
sleep(0.1)
t1 = _thread.start_new_thread(servo_temp,())
t2 = _thread.start_new_thread(prehod_barv,())
t1.start()
t2.start()
MRZLO.
VROČE.