I need a faster pwm than the one that is included that is why i am doing this.
This one is not working when i try to use the "tmr" as local variable, the tmr.delay just don't do anything in this case.
----------------------------------------------------------------------------------------------
function forwardandrewind()
local tmr = tmr
if(forward == 1) then
forward = 0
gpio.write(3,gpio.HIGH)
else
forward = 1
gpio.write(3,gpio.LOW)
end
for x=1,16000 do
gpio.write(4,gpio.HIGH)
tmr.delay(1)
gpio.write(4,gpio.LOW)
tmr.delay(1)
tmr.wdclr()
end
tmr = nil
print(node.heap())
end
This one is working when i try to use the "tmr" but leak memory.
----------------------------------------------------------------------------------------------
function forwardandrewind()
if(forward == 1) then
forward = 0
gpio.write(3,gpio.HIGH)
else
forward = 1
gpio.write(3,gpio.LOW)
end
for x=1,16000 do
gpio.write(4,gpio.HIGH)
tmr.delay(1)
gpio.write(4,gpio.LOW)
tmr.delay(1)
tmr.wdclr()
end
tmr = nil
print(node.heap())
end
Any suggestions?