TextMate Bundle for Arduino
The Arduino environment includes an IDE that enables you to write a program in the Arduino programming language, and upload it to your board. As nice as it is, i’d prefer to write code using TextMate, my programming weapon of choice.
There are several TextMate bundles for Arduino available on Github. I chose to install the Arduino TextMate Bundle from nasser. Using the command-line tools included with the latest Arduino software package, you can compile and upload Arduino programs right from within TextMate!
To get it to work, I had to tweak the Makefile included in the bundle. To access the Makefile, right-click on the “Arduino.tmbundle” stored in
~/Library/Application Support/TextMate/Bundles and choose “Show Package Contents”. The Makefile should be in the “Support” folder. These settings are used when you use the “Upload” (⌘U) command in TextMate.
Finding Your Device Name
When you installed the Arduino software environment on your Mac, it probably correctly identified your Arduino when you plugged it into the USB port. Check that the “Tools > Board” menu it properly set to “Arduino UNO”, and the “Tools > Serial Port” menu should identify the device name you are using (likely “/dev/tty.usbmodemXXX” or something similar). (Some tutorials suggest using “/dev/cu.usbmodemXXX” instead of the “tty.” device name on the Mac, but i’m not sure why.)
From Terminal.app, you can also list which devices show up when you connect your Arduino via USB. Check your device list before you connect your Arduino, and then check it again after you connect it. The device name is the new one that shows up.
Tweak Your Makefile
I have an Arduino UNO, which has the “atmega328p” processor. On a Mac (Snow Leopard v10.6.5), the UNO shows up as the device “/dev/cu.usbmodem411”. I also had to change the upload rate (serial baud rate) to “115,200” to get it to work properly. Here are the settings which worked for me:
ARDUINO_PORT ?= /dev/cu.usbmodem411 ARDUINO_UPLOAD_RATE ?= 115200 ARDUINO_AVRDUDE_PROGRAMMER ?= stk500v1 ARDUINO_MCU ?= atmega328p ARDUINO_F_CPU ?= 16000000
Note that you need to save your Arduino code (“sketch”) into a directory and file with the same name. For example, create a folder called “blink” and save your code in a file called “blink.pde”.