Simple lua controller blinker

From Pandorabox
Revision as of 14:16, 19 April 2021 by BuckarooBanzai (talk | contribs) (Created page with "A simple lua-controller based blinker Toggles the port '''A''' every 2 seconds === Simple version === <syntaxhighlight lang="Lua"> interrupt(2) port.a = not port.a </syntaxh...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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