0

I have an arduino galileo board, which I'm running using Intel's image on a micro-sd card. I already manage to run basic Lua scripts on it.

I want to run a Lua script on the board (Intel's image) and interact with the arduino interface - for example be able to turn on a led or read sensor data. This is very simple to do when using sketch directly, where you have straight forward API to turn on specific pin that is connected to a led. Same goes for reading input from a pin (check if sensor is sending data).

Is there a Lua library that has such access to the pins? or should I somehow connect the Lua script to the Arduino API?

The script will already run on the board.

Thanks.

0andriy
  • 4,183
  • 1
  • 24
  • 37
user1283002
  • 391
  • 1
  • 4
  • 12

1 Answers1

0

what you want to do is similar to the Firmdata; it is a processing and arduino sketch that will use arduino as a mere "executor" of a pseudo language over serial. That means many arduino command are mapped to a specific serial command, for example 'aX' may means do a digitalRead, where X is the pin number, 'bX' do an analogRead and so, obviusly arduino will then send back the reading to your host.

Drawback are that you are limited by serial (or any other bus) throughput. That means, if you want to just fast-prototipe something, it it a good solution, but when you need to code time-sensistive (or specialized) code, then you need to create your own function, called by your own command, witch probabily as a custom response.. pratically you are writing a custom program, and the ardiuno (and LUA) sketch become a mere string parser.

On galileo, the arduino is connected by serial port, as it is needed for sketch upload, so as long as LUA give you some library to manipulate serial port, you are good to go for this solution.

Lesto
  • 2,260
  • 2
  • 19
  • 26
  • I have an arduino with web connectivity, it is completely independent and runs the OS through the SD card (and available to me through SSH). It is not connected to anything physical. I have a lua script running on the device and want this script to perform actions like turning on LED or read and send (to my server on the internet) measures from a sensor. The thing I couldn't figure out is how I can access the PINs from the lua script. Is there any lua api that allows me to access these PINs (like I do using sketch)? or can my lua script run a sketch that does that? – user1283002 Mar 05 '14 at 09:13
  • your arduino has 2 component; the os chip and the atmega chip. They are connected only by serial bus. You have to write your own lua script that ask by serial the reading to the atmega,then you have to write a sketch on the atmega witch read the serial iterpretate the command, execute it and then send it back. There is a library that do this, is called firmdata but is processing (derived of java) – Lesto Mar 05 '14 at 09:26