22 lines
561 B
Lua
22 lines
561 B
Lua
function print_temp()
|
|
s = sensor.attach("DHT22", pio.GPIO18)
|
|
tmr.delayms(500)
|
|
while true do
|
|
print("Temperature : "..s:read("temperature").." Humitité : "..s:read("humidity"))
|
|
tmr.delayms(500)
|
|
end
|
|
end
|
|
|
|
function humi_neo(min, max)
|
|
s = sensor.attach("DHT22", pio.GPIO18)
|
|
neo = neopixel.attach(neopixel.WS2812B, pio.GPIO19, 8)
|
|
tmr.delayms(500)
|
|
pos = 0
|
|
while true do
|
|
neo:setPixel(pos, 0, 0, 0)
|
|
pos = math.floor((s:read("humidity") - min)/(max - min) * 8)
|
|
neo:setPixel(pos, 240, 150, 140)
|
|
neo:update()
|
|
tmr.delayms(500)
|
|
end
|
|
end
|