commit
This commit is contained in:
parent
07bcae8f43
commit
84036b5d43
2 changed files with 23 additions and 0 deletions
22
dht22.lua
Normal file
22
dht22.lua
Normal file
|
@ -0,0 +1,22 @@
|
|||
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
|
Loading…
Add table
Add a link
Reference in a new issue