15

Can I program my Arduino using any programming language other than C++? If so, which programming languages? What software would I need for compiling and loading my code onto the Arduino?

5
  • 1
  • Unfortunately, this is an effective duplicate of an non-Arduino.SE question: see here I think the question I linked should be moved here after beta ends, but not just yet.
    – apnorton
    Feb 13, 2014 at 2:58
  • @anorton That question is asking about alternative IDEs. This question is not a duplicate because it talks about alternative programming languages.
    – tstew
    Feb 13, 2014 at 3:02
  • @user2202326 Sorry... I seemed to recall more people responding with different languages than IDEs on that thread, but, apparently, I was wrong. Carry on.
    – apnorton
    Feb 13, 2014 at 3:04
  • You could look into Netduino if you are familiar with C# (Visual Studio is the way to go, but there are other ways to compile C# code). I don't know what board you have and if it is compatible though. netduino.com
    – Jason Down
    Feb 13, 2014 at 16:39

5 Answers 5

5

Some commonly known ones:

In theory you should be able to extend avr-gcc to support other languages, though this is no small undertaking. I should also caveat that support for languages other than C typically comes with some fairly weighty restrictions on language components -- for instance, even with C++ it's discouraged to be instantiating new objects as malloc and free are extremely expensive in both memory space and cycles.

Besides using Google, the following references are applicable Click Here.

9

In theory, any compiler which outputs AVR assembly could be used (modulo limitations on code size, ram usage etc).

AVR backends exist for both LLVM and GCC -- so in theory, with some effort, most languages which are supported by LLVM and GCC's front-ends could be compiled to AVR. A big question will be library support, etc.

Never the less, here's a couple of odd choices for the spirit of the question, rather than its letter [1].

  • AMForth, a forth dialect can be flashed onto an Arduino.
  • AVR-Ada: Ada for AVR micro-controllers.
  • BASIC: Bring back the Goto!

Oh, and you could write raw AVR Assembly!

[1]- I Haven't tried these though!

2

There are also some people working on Javascript node.js based systems. One that is already publicly available is Espruino and another is Tessel which launches in spring 2014.

2

I'm surprised that nobody has mentioned AVR Assembly!

Assembly is not often thought to be the most interesting, or even an easy method of programming, but it's nonetheless, 100% possible with all AVR based arduino. SAM boards will likely not work with this flavor, but it's still possible to use assembly in their programming.

All Arduino boards (as of posting) support assembly programming via Atmel Studio, The SDK made for Atmel based chips.

Assembly is naitively supported by all Atmel devices, and requires no boot loader in order to work, so all programs are inherently real-time.

2
  • 2
    Note that assembly is also supported by the gcc toolchain, which is included in the Arduino IDE install. Jun 13, 2019 at 16:45
  • @EdgarBonet Correct, which is why the __asm__("Assembly code here") works to add in-line assembly to any sketch. For most programs, this is a bad idea, however, as it's difficult to achieve platform independence with this method.
    – tuskiomi
    Jun 13, 2019 at 16:54
1

Because avr-g++ should support all standard C / C++ constructs it is possible to code inline assembly. More info on this arduino.cc forum thread

3
  • Inline assembly isn't part of the C/C++ standards, but gcc and the microsoft c compiler support it, although incompatibly.
    – tbodt
    Feb 17, 2014 at 1:02
  • true, and so do the avr_gcc.
    – Faux_Clef
    Feb 18, 2014 at 12:34
  • Nothing beats writing executable code in hex anyway.
    – Faux_Clef
    Jun 10, 2017 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.