import neopixel
from machine import Pin, ADC
from time import sleep
import random
import dht
NUM_LED = 16
leds = neopixel.NeoPixel(Pin(16), NUM_LED)
hm = neopixel.NeoPixel(Pin(5), NUM_LED)
gumb=Pin(14, Pin.IN)
pot=ADC(Pin(25))
sense = dht.DHT22(Pin(17))
def convert(x, in_min, in_max, out_min, out_max):
return (x - in_min) * (out_max - out_min) // (in_max - in_min) + out_min
while True:
leds.fill([0,0,0])
r=255
g=0
b=0
z=round(255/NUM_LED)
i=15
if gumb.value()==0:
leds.fill([0,0,0])
for x in range(NUM_LED):
s=(convert(pot.read(),0,4096,0,101))*0.01
sense.measure()
hm.fill([100+round(sense.temperature()),50,100+round(sense.humidity())])
hm.write()
leds[x]=[r,g,b]
leds.write()
sleep(s)
g+=z
hm.fill([0,0,0])
hm.write()
if gumb.value()==1:
leds.fill([0,0,0])
for x in range(NUM_LED):
s=(convert(pot.read(),0,4096,0,101))*0.01
sense.measure()
hm.fill([100+round(sense.temperature()),50,100+round(sense.humidity())])
hm.write()
leds[i]=[r,g,b]
leds.write()
sleep(s)
g+=z
i-=1
hm.fill([0,0,0])
hm.write()