commit
This commit is contained in:
parent
89886ac0ea
commit
52c5047699
6 changed files with 199 additions and 11 deletions
35
pwm.lua
Normal file
35
pwm.lua
Normal file
|
@ -0,0 +1,35 @@
|
|||
-- écrit le 12/10/2024 par Lukian Leizour
|
||||
|
||||
function rgb(r, g, b)
|
||||
-- on attache et démarre les pins
|
||||
red = pwm.attach(pio.GPIO21, 2000, r / 256); red:start()
|
||||
green = pwm.attach(pio.GPIO19, 2000, g / 256); green:start()
|
||||
blue = pwm.attach(pio.GPIO18, 2000, b / 256); blue:start()
|
||||
|
||||
-- on attend 5 secondes
|
||||
tmr.delayms(5000)
|
||||
|
||||
-- on stoppe et détache les pins
|
||||
red:stop(); red:detach()
|
||||
green:stop(); green:detach()
|
||||
blue:stop(); blue:detach()
|
||||
end
|
||||
|
||||
function allrgb()
|
||||
-- on attache et démarre les pins
|
||||
red = pwm.attach(pio.GPIO21, 2000, 1.); red:start()
|
||||
green = pwm.attach(pio.GPIO19, 2000, 0); green:start()
|
||||
blue = pwm.attach(pio.GPIO18, 2000, 0); blue:start()
|
||||
|
||||
-- on boucle pour afficher toutes les couleurs RGB
|
||||
for i=0,255,5 do green:setduty(i / 256); tmr.delayms(50) end
|
||||
for i=255,0,-5 do red:setduty(i / 256); tmr.delayms(50) end
|
||||
for i=0,255,5 do blue:setduty(i / 256); tmr.delayms(50) end
|
||||
for i=255,0,-5 do green:setduty(i / 256); tmr.delayms(50) end
|
||||
for i=0,255,5 do red:setduty(i / 256); tmr.delayms(50) end
|
||||
|
||||
-- on stoppe et détache les pins
|
||||
red:stop(); red:detach()
|
||||
green:stop(); green:detach()
|
||||
blue:stop(); blue:detach()
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue