Homepage Wiki Forum Buy

LUA

From GNUBLIN

Contents

Lua Skripts

hello.lua:

print ("Hello World!\n")

run:

lua hello.lua


application examples

For LUA applications, a small library was written and calledelektor.lua. You find this library in the directory /root/examples/misc/gpio/ on the Debian rootfs or in /home/root on ELDK rootfs.


LED BLINK

The LUA scripts can be started as follows

/root/examples/misc/gpio/blink.lua


require "elektor"

-- initialize hardware

initLED()

-- start main loop

print("blinking ...")

while 1 do
  setLED()
  wait(1)
  clearLED()
  wait(1)
end


If everything fits, then the red on the board start to blink.

To stop the script you have to press Ctrl-z.


PROBE REQUEST

The LUA scripts can be started as follows

/root/examples/gpio/button.lua


require "elektor"

-- initialize hardware

initButton()
initLED()
initRelay()

-- start main loop


while 1 do
  if getButton() == '1' then print("Button not pressed") else print("Button pressed") end
end


Sample programs / library

In other languages