lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



The rpi-gpio module is available in the luarocks repository and can be installed (on Raspberry Pi only) using `sudo luarocks install rpi-gpio`.


The module provides support for the Raspberry Pi builtin General Purpose Input Output (GPIO) interface, and allows you to create and control electronics projects from Lua.


It is a binding to the code of Ben Croston (Python GPIO module) [1], based upon the works of Andre Simon [2] and further extended by me. Where Andres’ Lua binding code only supported basic input output pins, the module now supports all features of the Python module.


- basic input/output pins

- PWM support (software based)

- edge detection (falling/rising/both)

- asynchronous callbacks based on edges


Examples [3] for all of these are available in the repo [4] to get going quickly.


Not in the python module, and hence not in the Lua binding (a.o.)

- I2C

- Serial

- hardware PWM

But I intend to add those as they come available in the Python module


The asynchronous callbacks are implemented using darksidesync [5] which is not a rock dependency, so you’ll have to manually install it using `sudo luarocks install darksidesync` (but only if you intend to use callbacks). See example 6 [6] on how to use those (also requires the ‘copas’ module)


Best way for a quick start is through the Lua readme [7] and the examples [3].


Enjoy! And as always comments are welcome!