The Arduino IDE might be good for beginners, but it’s not my usual text editor, so I don’t like it. That being said, what do we need to do in order to compile stuff as usual C programs, and upload them to the board? Using a bit of google-fu we get to several arduino makefiles. I found that this one looked alright but ultimately settled or a fork of that repo which had a bunch of bugfixes and new features like autodetecting versions and so on.
I’m running Ubuntu 11.04 and the Arduino packages aren’t up to date, so I just downloaded and decompressed the main folder to a directory
which we’ll call
/arduino/arduino from now on. I then downloaded the makefile repo from github which you can find here.
I put the makefile repo alongside the arduino folder in
Let’s get the blink program working. Create a folder in
/arduino/blink with a
I’m using a duemilanove with a 328 so that’s what I need to put in my makefile. If you got a new Uno just
sed -i "s/atmega328/uno/" makefile.
Also keep an eye on the port your board is using but
/dev/ttyUSB0 should be ok if you’re not on a wierd system (ie: not Linux). My makefile:
Now you can run
make and to be sure everything is okay. When I running
make upload I got an error saying:
By looking into the code in
Arduino.mk, it looks like we could solve it by telling the each and every makefile where
We can also just put the files where the makefile expects them to be. So we’ll do that instead.
Now you’re a
make upload of seeing something like this:
And your Arduino should be blinking away. For programs which use other libraries, you now need to include them as you normally do in C. The makefile is doing its magic by linking the Arduino basic ones so if for example you were to use the Serial library to do something useful like counting to 1000 (note the include at the top):
If you need help visualizing, your tree should look something like this:
UPDATE: After all this, someone showed me inotool which has a bunch of cool features and is simpler to set up and use. Check it out.