jenswilly.dk


TextMate Bundle for Arduino 0017

17. November 2009 16:07 by Jens Willy Johannsen
Categories: Arduino

TextMate Bundle to build and upload Arduino sketches

Far be it from me in any way, shape or form to criticize the Arduino IDE which is simple, easy to use and works flawlessly (at least I have never had any problems). However, there are times when I find it preferable to write the Arduino sketches in TextMate (which is the text editor for Mac, in case you didn't know) since it has better... well, text editing functions. Until yesterday I frequently wrote/edited the sketches in TextMate and then copied the text over to the Arduino IDE in order to upload the sketch.
There are several guides on compiling and uploading from the command line and also several TextMate bundles for doing this but I couldn't get any of them to work on my setup (Mac OS X 10.6.1, Arduino Duemilanove and Arduino 0017) so I had to hack one together myself using bits and pieces from the other available bundles and documentation from various forums.

Here it is: TextMate bundle for Arduino 0017

Assumptions
This bundle assumes that the Arduino IDE version 0017 is installed in /Applications and it named "Arduino". If this is not the case you need to change a path in the makefile (refer to the section about messing with the Makefile).

How to use it

  • Extract the zip and double-click the .tmbundle file to install it in TextMate (which, of course, you will need to have installed beforehand).
  • Create a new document in TextMate, write some Arduino code (or copy/paste in the sample Blink code) and save the file with a .pde extension
  • Hit Cmd-R to compile and upload the sketch

You can also hit Cmd-B just to compile without uploading (to check your syntax).

Note that a folder named "applet" will be created in the same location as the .pde file during compilation. (You can delete it if you want or leave it in place.)

MCU and F_CPU settings
The Makefile needs to know what AVR processor and which clock speed to compile to. The defaults are ATmega328 and 16 MHz (i.e. a standard Arduino Duemilanove).
These values can be overridden by setting other values in TextMate's preferences. In the TextMate preferences, choose the "Advanced" tab and click "Shell Variables". Add the following variables to override the default values:

Variable Value
TM_ARDUINO_MCU atmega328p|atmega168|...
TM_ARDUINO_F_CPU 16000000|8000000|...

For example, the following settings will compile for an ATmega168 running at 8 MHz:
TextMate preferences

If one or both of the above variables are deleted or disabled, the default values will be used.

Messing with the Makefile
If you need to change something in the Makefile (e.g. the path to the Arduino tools) go right ahead and do it.
The Makefile is located in the bundle. The bundle is located in ~/Library/Application Support/TextMate/Bundles. Option-click and choose "Show Package Contents" and then open the "Support" folder and edit the Makefile to your heart's content.

Comments 5 comments »