import dht
from machine import Pin, PWM
import neopixel
from servo import Servo
import time


servo = PWM(Pin(15), freq=50, duty=0)
# servo gre naokoli 180 stopinj!!
for i in range(45, 110):
    Servo(servo, i)
    time.sleep(0.02)

nl = 32
nl2 = nl//2
leds = neopixel.NeoPixel(Pin(18), nl)
redSteps = 255//nl
'''
for i in range(nl):
    leds[i] = [i*redSteps, 255 - (i*redSteps), 0]
leds.write()
'''

# DHT senzor!!
sense = dht.DHT22(Pin(4))
x=0
while True:
    if x % 2 == 0:
        for i in range(nl2):
            leds[i] = [255 - (i*redSteps), i*redSteps, 0]
            time.sleep(0.05)
            leds.write()
        for i in range(nl2,nl):
            leds[i] = [i*redSteps, 255 - (i*redSteps), 0]
            time.sleep(0.05)
            leds.write()
    else:
        for i in range(nl2,nl):
            leds[i] = [255 - (i*redSteps), i*redSteps, 0]
            time.sleep(0.05)
            leds.write()
        for i in range(nl2):
            leds[i] = [i*redSteps, 255 - (i*redSteps), 0]
            time.sleep(0.05)
            leds.write()        
    x += 1
    leds.fill([0,0,0])
    leds.write()