Arduino from the command line in Ubuntu 12.04

Posted on Friday, June 22nd, 2012 in Arduino, code, how-to by the machinegeek

Martyn Davis is an Arduino enthusiast whose operations have outgrown the stock Arduino GUI IDE.

“If you’ve done more than a bit of programming in the past, you’ll soon find the dinky IDE a little frustrating to use. For example, my preferred text editor, by far, is vim, and I find it quite jarring to be forced to use a basic text editor to build programs. Yes, you can select “use external editor” in the settings, but it’s clumsy. I’ve built many an Arduino program in vim, then switched to the Arduino IDE to build it. It’s just not streamlined – it’s too slow and clunky.

It was therefore with delight I saw in the kubuntu 12.04 repository (I recently re-installed everything on my desktop after falling back in love with KDE) that there’s a package called arduino-mk which promises to provide the ability to build arduino programs directly from the command line. Which means you can use vim (or emacs if you’re weird) and makefiles.”

Follow the details after the fold.

Noting that arduino-mk doesn’t work out of the box, Martyn Davis has written this article describing the steps he found necessary to get Arduino programming up and running from the command line.

His instructions build on the excellent foundation on this subject by Martin Oldfield, developer of arduino-mk. See “Martin’s Atelier” website for additional details and links to download the code libraries (recently updated for use with Arduino 1.0.)

This entry was posted on Friday, June 22nd, 2012 at 12:30 am and is filed under Arduino, code, how-to. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.

11 Responses to “Arduino from the command line in Ubuntu 12.04”

  1. Brian says:

    vim and Arduino, now that is an odd couple.

    • Jim says:

      No kidding! You’d think that if he’s a vim user, he’s probably be a power user and would have graduated to full-on AVR programming (plain C and inline assembly and maybe using the Arduino as an ISP if he’s too cheap).

      Weirder than using emacs, that’s for sure.

      • davek says:

        Switching to straight-up AVR development leaves behind a lot of community and code. The Arduino layer really does bring a lot to the table, it just doesn’t bring much in the way of editor.

        For those who aren’t looking for vim, CodeBlocks Arduino Edition or VisualMicro (Visual Studio extension) might be an option.

      • Barnaby Jackson Pollock says:

        That’s my eventual plan. Baby steps, though. Just got my uno, and I’m going to let the IDE hold my hand until I’ve made an LED flash or something. Then I’m going to get down into the weeds and figure out what the ide’s hiding from me. In the meantime, it’ll be wonderful not to have to give up vim.

        Honestly, if you program or do a lot of plaintext editing of any kind, you’re a masochist if you’re not using vim, emacs, or some similarly full featured editor. You really can’t comprehend how much time you’ll save until you’ve used it for a while and actively learn the shortcuts. RSI sucks, take precautions now.

  2. Benjamin Fiset-Deschenes says:

    One day I will learn the power of vim!

  3. MikeSmith says:

    Alternatively, there’s a cross-platform Makefile (OS X, Linux, Windows/Cygwin) for Arduino here:

    that faithfully emulates the IDE’s handling of sketches, libraries, .ino files, etc. etc. with less configuration.

    (shameless plug – I originally wrote this)

    = Mike

    • davek says:

      Cool, thanks, I may be able to use this. It looks pretty straightforward to use, do you happen to know if it’ll work against the arduino-core deb package?

  4. MikeSmith says:

    The Arduino dependencies are pretty straightforward; worst case you may have to set ARDUINO to help it find the core depending on where the package ultimately installs it.

  5. Bogdan says:

    Arduino is very good when you want to write a program fast, because it has many libraries.
    Although I’m very familiar with the AVR (peripherals, assembler instructions), there are many times when I just want to write a small program fast, and then I use Arduino and it’s libraries.
    After the initial prototyping, if you need to optimize the program, but keep the logic, it’s ok to rewrite it in plain C without using the Arduino libraries.

  6. Ivan Kravets says:

    I want to propose you alternative way to build Arduino-based source code from the CLI without any dependencies. You don’t need to install any toolchains from apt-get repo or even Arduino IDE. Just try PlatformIO:

    $ platformio install atmelavr

    # then initialise empty project within empty dir
    $ platformio init

    # now you can build + upload
    $ platformio run -t upload

    P.S: Don’t forget that PlatformIO has internal Library Manager. You can search/install/update libraries from one place within your CLI.

Leave a Reply

Notify me of followup comments via e-mail. You can also subscribe without commenting.

Recent Comments

  • Max: Hey, good job quoting as an abstract something the author writes about someone else's project... For the record, I do appreciate the proper attention to...
  • imqqmi: Also interesting to note that arduino's use the DTR signal to reset the device. I found this out because repetier was able to do this...
  • Kevin: A bit sad that you are using a knock off Saleae device unless you are not using Saleae software.
  • Max: For the Haxxor Edition he could add a Morse-to-scan-code translator to the code in the PIC (where the L337 Haxxor Special also accepts Unicode code...
  • KH: Someone with a PIC16F1459 project, well you don't see these every day. Methinks he repeats the USB 2.0 thing too much; this might mislead people...