Using an external editor for Arduino development

The Arduino IDE is nice to get beginners started, but you’ll quickly hit its limitations. And if, like me, you found an option in the preferences dialogue that enables an external editor, you’ll have been disappointed to find that it seems only to disable the internal editor!

It is possible to work entirely outside the IDE, with your own editor (like Emacs or Eclipse) and build your projects from the command line (or in another IDE). Here’s one way to do it…

You should make sure that the Arduino IDE is working first. This will ensure the compiler, C-library an Arduino libraries are installed and working correctly and that you can communicate with your Arduino. Then you’ll want to use a Makefile. I’ve spent some time writing one, in collaboration with quite a few other people, an it’s available here. It’s very easy to use, quite fully-featured, and as compatible with the IDE as possible. (Other makefiles also exist, of course.)

OK, so to build your project outside the IDE, you’ll need to do the following:

  1. Download the `arduino.mk` ([from here](http://ed.am/dev/make/arduino-mk)). You should save it somewhere accessible, like in your home directory. I keep mine at `~/src/arduino.mk`.
  2. In your project directory, edit your main file and save it as a `.ino` file, just as you would in the IDE.
  3. Create yourself a `Makefile`, with the following in:

    BOARD = uno
    include ~/src/arduino.mk

    Obviously, you should replace `~/src/arduino.mk` with the location you saved the Aruino makefile. Having saved `Makefile`, you can run `make boards` to see what board names exist. Then, you should set the `BOARD` variable correctly (“uno” may not be correct).

And that’s it!

To build your project, you should only have to type

$ make

To upload it to the Arduino board, go

$ make upload

(If it can’t detect your Arduino by its self, you may need to set the SERIALDEV variable in your Makefile.)

And if you want to use the Serial Monitor from the Arduino IDE without running the IDE, you can achieve this by going

$ make monitor

This actually runs GNU screen. (You’ll need to remember the shortcut keys to kill screen (^a k, by default) so that you can get out of it!)

If something goes wrong or isn’t working, you should have a look at the documentation for arduino.mk.

Email this to someoneShare on RedditShare on FacebookTweet about this on TwitterShare on Google+

23rd November, 2012 — computing — 1 comment

comments feed

Comments

  • Domas
    22nd January, 2014 at 1:42 pm
    reply
    permalink

    Very informative post. I succesfully compiled and uploaded code from terminal. I edit the code using Kate editor.

Leave a Reply to Domas




XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*/?>

Cancel Reply

    • Home
    • About Me
    • Photography
    • Software
      • Android
        • Export Contacts
        • Import Contacts
        • How to install an APK
      • GTK-based
        • Manage Raws
        • Prep. Images
      • Makefiles
        • Arduino
        • General-purpose
      • sqlite3cc
  • Page Content

  • Categories
  • Archives
  • Meta
    • log in
    • site feed
  • Thanks!
    • Send me bitcoins
    • Flattr this

powered by WordPress and Gallery2   |   hosted at waxworlds.org   |   site design by edam