I want to write code for my Arduino in Lua. Where I can find the necessary (pins) I/O lib and examples for Arduino IDE?
UPD: I've got arduino mega with many memory.
-
1You want to code in Lua? And have that code run on the Arduino? Which Arduino do you have in mind?Nick Gammon– Nick Gammon ♦03/20/2016 19:52:35Commented Mar 20, 2016 at 19:52
-
@NickGammon , that's true, I want to write program for arduino uno.val - disappointed in SE– val - disappointed in SE03/20/2016 20:18:59Commented Mar 20, 2016 at 20:18
-
@NickGammon: ok, now I've got an arduino mega.val - disappointed in SE– val - disappointed in SE08/17/2016 16:40:25Commented Aug 17, 2016 at 16:40
-
1It looks like the ESP8266 runs Lua, but I haven't seen it running on an Arduino.Nick Gammon– Nick Gammon ♦08/17/2016 21:57:57Commented Aug 17, 2016 at 21:57
2 Answers
Lua is an interpreted language. That is, the compile phase turns Lua source code into intermediate "pseudo-code" which the Lua interpreter then runs. It doesn't compile into machine code, and therefore there is nothing that could be uploaded to your Uno as a "hex" file.
In any case, with only 2 KB of RAM, it wouldn't be very practical to attempt to run Lua on a Uno. I like Lua personally, but running it on the (AVR) Arduinos just isn't practical.
-
Lua is a language (a spec of syntax and semantics). Its most widespread implementation is an interpreter, but there is nothing in the Lua language that prevents one from writing a compiler that emits Arduino code (or any other code). I find it actually unexpected that no one has made it yet.Gabriel– Gabriel03/15/2018 12:49:36Commented Mar 15, 2018 at 12:49
AFAIK, Arduino IDE supports C++ only. You can use other languages to communicate with Arduino from your PC. Take a look at Firmata.
-
An enterprising person might cross compile
Lau
toC++
... Once upon a time our AT&T C++ compiler only emmitted C and thecc
command turned that into object coed.will– will07/30/2023 13:31:41Commented Jul 30, 2023 at 13:31