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
|
1
main.lua
1
main.lua
|
@ -2,6 +2,7 @@
|
||||||
dofile("out.lua")
|
dofile("out.lua")
|
||||||
dofile("neopixel.lua")
|
dofile("neopixel.lua")
|
||||||
dofile("encoder.lua")
|
dofile("encoder.lua")
|
||||||
|
dofile("dht22.lua")
|
||||||
|
|
||||||
-- fonction permettant d'afficher la température du CPU
|
-- fonction permettant d'afficher la température du CPU
|
||||||
function printTemp()
|
function printTemp()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue