Interfacing with Lua

LUA Installation
First, LUA 5.1 should be installed.

On Linux: sudo apt-get install lua5.1 sudo apt-get install liblua5.1-0-dev sudo apt-get install libusb-1.0-0-dev

On Windows: ?

On Mac OS X (with Homebrew): brew install lua

Launch it in a terminal, then type print("LUA is ready !!") and hit Enter.

The result should be: LUA is ready !!

Congratulations, LUA is installed !!

Now to communicate with USB, you need a libusb binding for LUA.

Download it here

Extract it : tar xvzf lualibusb-0.4.tar.gz

To compile this package you need the liblua5.1-0-dev package of LUA and libusb-1.0-0-dev.

That's why we installed it before.

Open the Makefile in the lualibusb folder and change the first 2 lines to point to the good folders, the lines for me were:

LIBUSB_SRC = /usr/include/libusb-1.0 #change with your libusb sources folder LUA_SRC = /usr/include/lua5.1   #change with your lua sources folder

Then compile this libusb binding. make

Now you should find a lualibusb.so file in the folder. Rename this file to libusb.so and copy it in /usr/local/lib/lua/5.1/

If this folder doesn't exist, create it.

mv lualibusb.so libusb.so sudo mkdir -p /usr/local/lib/lua/5.1/ sudo cp libusb.so /usr/local/lib/lua/5.1/

Now your libusb binding is installed. Try it:

lua Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio >require('libusb') >

Everythig is OK, now you can try LUA with your Pinguino.

On Computer Side
Save these lines as temp18b20.lua

You will also need this little script to use the keyboard.

Type the following lines in your editor and save it as testkbd.sh

Launch the program in a Terminal with : lua temp18b20.lua