12

I like the idea of using the Arduino IDE for simple projects and for getting started with Arduino, but the consensus I've gotten so far is that it is for those who are new to Arduino and/or programming in general.

My understanding is that it is possible to write a C program from scratch, completely outside of the Arduino IDE, and then use a tool like AVRDUDE to upload it to an Arduino MCU. This option, albeit appealing and interesting, leaves me with a few concerns:

  • What Arduino libraries would need to be imported/linked by such a "raw C" program? I assume that when an Arduino IDE-based program executes a digitalWrite(...) it is really calling a C lib, probably provided by Arduino, under the hood. I am concerned about making sure all these "underlying libs" get included with my C program. Thoughts?
  • Is anything else "lost" by flying solo and venturing outside the Arduino IDE? Any capabilities/features that I would now have to "roll my own"?
1
  • arduino.stackexchange.com/questions/9538/… The answers on my question helped me to set it up. You can replace/leave out anything from arduino. You can: -Make your own board. -Use your own IDE. -Use your own libraries.
    – aaa
    Commented May 7, 2015 at 6:22

3 Answers 3

4

Here you are two nice articles how Arduino actually works in background. How it removed friction from microcontroller programming.

  1. A Tour of the Arduino Internals: How does Hello World actually work?
  2. Arduino and GCC, compiling and uploading programs using only makefiles

It was also discussed here Is there a way or tutorial for converting Arduino code to C code?

4
  • Thanks @Michal Foksa (+1) - I guess I'm just shocked that the answer to this isn't much more well known! I would have thought that the Arduino IDE had, say, a lib/ directory somewhere under its installation root that had things like arduino-core.dll, arduino-io.dll, etc.
    – smeeb
    Commented May 5, 2015 at 19:16
  • @smeeb: You're correct, the Arduino IDE installation does - has to - include libraries of the basic run-time functions plus user supplied ones. Halfway down the page of link 2, in the makefile, the symbol LIBS points to them. They aren't .dlls (which in Windows, are called at run-time); they are object files (.o under unix-like systems, probably the same under Windows) that are statically linked with your compiled object files into (ultimately) a .hex load file, which is the complete loader image. ...
    – JRobert
    Commented May 5, 2015 at 20:00
  • ... It is well known to people who write programs for a living, but the Arduino (brand) tool designers have deliberately hidden as many of the messy details as possible to make applying digital electronics available to people without them having to become professional level programmers and engineers to do it. To the extent you're finding this information hard to find in the Arduino community, they've been successful!
    – JRobert
    Commented May 5, 2015 at 20:05
  • Unfortunately, for legacy reasons, you build Arduino software quite differently than the standard accepted way. In 'removing friction' to make it simple, they created a huge incompatible community. Every IDE 'plugin' is an attempt to make something not standard work in near standard way. Keep that in mind as you run into problems.
    – user6569
    Commented May 6, 2015 at 6:40
5

You're absolutely right about needing to link against other libraries. However, you don't necessarily need to worry about all of the details yourself, unless you want/need to do something unusual. Several alternative IDEs already support Arduino, typically via plugins which handle a lot of the details automatically.

I normally recommend Eclipse as it's a very widely used IDE for various purposes. However, there are several other possibilities. See this question for more information:

4
  • Thanks @Peter R. Bloomfield (+1) - however I'm really looking for a non-IDE centric answer. Not that I have anything against IDEs, it's just that in order to understand the "library landscape" of Arduino, I feel like IDEs are just an unnecessary middle man. Having said that, I would assume that there are 1+ "core libs" that ALL Arduino apps must link with, and that there are then optional libs that you may or may not need, depending on what your app actually does. Can you point me to a list of these "core libs", as well as any other optional ones? Thanks again!
    – smeeb
    Commented May 5, 2015 at 17:09
  • And to qualify what I was saying above about IDEs being "unnecessary middlemen", what I really mean is: I should be able to write a C app outside of any IDE (Arduino, Eclipse, or otherwise), link to the Arduino libs that my app needs, and still compile/deploy the app to Arduino hardware. I'm wondering what those libraries are, and where I can find documentation on them.
    – smeeb
    Commented May 5, 2015 at 17:10
  • @smeeb Given that Arduino is aimed at beginners, I don't think there's much (if any) official documentation along those lines. I expect the best way to research it would be to search online for examples of Arduino makefiles. There are some old examples near the bottom of this page. Commented May 5, 2015 at 18:22
  • @smeeb: Like you, I am not fan of IDEs. There are a few generic Arduino makefiles floating on the Web. You basically have to compile the Arduino core library into libore.a, then compile your .ino file with -x c++ -include Arduino.h for your compiler to understand it (plus a bunch of -D, -I, etc) and link with libcore.a. Commented May 7, 2015 at 8:04
1

Yes, you can write a program outside Arduino IDE. For example I tried Eclipse IDE with AVR plug-in and now I stick with AVR Studio. Of course,you won't have some functions that you maybe usually use when you write in Arduino IDE and also some libraries. But, why not to try implementing stuff. Why to limit yourself to functions and libraries made by others when you can learn and write your owns, maybe better than the existing ones.

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.