1
0
mirror of https://github.com/elua/elua.git synced 2025-01-08 20:56:17 +08:00
elua/romfs/pwmled.lua
Bogdan Marinescu 747da02673 - made the math lib configurable with the "platform libs" mechanism. This way one can have a floating point Lua (thus being able to use fundamental floating point operations), but without the
mathlib (sin, cos, tan and all the other functions from there).
- corrected "pwmled.lua" (removed a debug print)
- bumped version number to minor versn 0.4.1
2008-09-10 18:41:31 +00:00

27 lines
634 B
Lua

-- Control LED intensity with PWM
local pwmid, tmrid, ledpin
if pd.board() == 'EK-LM3S8962' or pd.board() == 'EK-LM3S6965' then
pwmid, tmrid = 0, 1
pwm.setclock( pwmid, 25000000 )
else
print( pd.board() .. " not supported by this example" )
return
end
print "Control LED with PWM (fade up/down)"
print "Press any key to exit"
local crtduty, incr = 10, 5
pwm.setup( pwmid, 50000, crtduty )
pwm.start( pwmid )
while uart.recv( 0, 0, 0 ) < 0 do
if crtduty == 95 or crtduty == 5 then
incr = -incr
end
crtduty = crtduty + incr
pwm.setup( pwmid, 50000, crtduty )
tmr.delay( tmrid, 50000 )
end
pwm.stop( pwmid )