Arduino is “an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It’s intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments.”

The Arduino IDE is useful for beginners, but Emacs is better.

To compile sketches outside of the Arduino IDE, you will need to use which is comes with the Arduino development environment. This enables command line compilation of your sketches, and is used by the CEDET support.

Alternately, to use the Arduino IDE for compilation, but edit in Emacs, open the preferences in the IDE, and choose “Use External Editor”.

Emacs + - Quickstart for Linux

BOARD_TAG = uno (see make show_boards)
ARDUINO_LIBS = <space separated list of libs, will try to guess>
MONITOR_PORT = /dev/ttyUSB0 (will be automatically guessed from IDE prefs)
include /usr/share/arduino/

Arduino Support for OS X

This is what I did in order to get Arduino support for OS X:

Install CEDET

CEDET is a very complex and powerful package, but I will perform a simple installation from the bazaar repository:

~/.emacs.d/vendor $ git clone cedet
~/.emacs.d/vendor $ cd cedet
~/.emacs.d/vendor $ make EMACS=/Applications/

or, if you are using Aquamacs, instead of using make open ~/.emacs.d/vendor/cedet/cedet-build.el in Aquamacs then:

M-x eval-buffer
M-x cedet-build-in-this-emacs

Then, following the INSTALL file, add this to your emacs config file:

;; Load CEDET.
;; See cedet/common/ for configuration details.
;; IMPORTANT: For Emacs >= 23.2, you must place this *before* any
;; CEDET component (including EIEIO) gets activated by another 
;; package (Gnus, auth-source, ...).
(load-file "~/.emacs.d/vendor/cedet/cedet-devel-load.el")

;; Add further minor-modes to be enabled by semantic-mode.
;; See doc-string of `semantic-default-submodes' for other things
;; you can use here.
(add-to-list 'semantic-default-submodes 'global-semantic-idle-summary-mode t)
(add-to-list 'semantic-default-submodes 'global-semantic-idle-completions-mode t)
(add-to-list 'semantic-default-submodes 'global-cedet-m3-minor-mode t)

;; Enable Semantic
(semantic-mode 1)

;; Enable EDE (Project Management) features
(global-ede-mode 1)

;; Configure arduino OS X dirs.
(setq ede-arduino-appdir "/Applications/")

You must add the last line in order to tell CEDET the path where the Arduino libraries are.

Install Arduino mode

Go to your emacs config directory and get a git copy of the Arduino-mode:

~/.emacs.d/vendor $ git clone git://

Configure your emacs init file to use it:

(add-to-list 'load-path "~/.emacs.d/vendor/arduino-mode")
(setq auto-mode-alist (cons '("\\.\\(pde\\|ino\\)$" . arduino-mode) auto-mode-alist))
(autoload 'arduino-mode "arduino-mode" "Arduino editing mode." t)

Install Arduino IDE

Download the IDE and move it to your Applications folder. Connect your Arduino to the USB port, compile the blink example, and upload it. Verify that everything works fine. After that, from a terminal shell, create a directory in your $HOME folder and add a link to it following this steps:

~/ $ mkdir .arduino
~/ $ cd .arduino
~/.arduino $ ln -s /Users/yourusername/Library/Arduino/preferences.txt .

Install Arduino-cli tools

We need this tools in order to create the Makefile file. I downloaded them in my /opt/local/share dir.

/opt/local/share $ sudo git clone git://

Edit the file inside the new Arduino-Makefile/arduino-mk directory. Modify and uncomment this lines according to your installation:

   ARDUINO_DIR   = /Applications/
   ARDMK_DIR     = /opt/local/share/Arduino-Makefile

Add a link in your ARDUINO_DIR to the file:

/Applications/ $ ln -s
/opt/local/share/Arduino-Makefile/arduino-mk/ ./

Install required Perl modules

Do this as root:

sudo /usr/bin/perl -MCPAN -e shell


cpan[1]> install YAML


cpan[2]> install Device::SerialPort

Test the installation

Open a .ino file. C-c . c will create the makefile and compile the code. C-c . U will upload it to the arduino. If you get this error: Cannot invoke project-compile-target, try M-x global-ede-mode.