Simple lua controller blinker

From Pandorabox
Jump to navigation Jump to search

A simple lua-controller based blinker

Toggles the port A every 2 seconds

Simple version

interrupt(2)
port.a = not port.a

Verbose version

This example shows all the various events in play:

if event.type == "program" then
 -- initially triggered by the "program" button on the LuaC
 -- start the interrupt timer
 interrupt(2)
end

if event.type == "interrupt" then
 -- triggered by the expiration of the interrupt timer
 port.a = not port.a
 -- trigger again in a few seconds
 interrupt(2)
end


NOTE: be aware of the per-mapblock mesecons restrictions if you intend to decrease the interval, see Mesecons speed advices