I’ve found that most tutorials relating to Xcode and Arduino don’t work. For the most part it seems that the arduino IDE gets an upgrade and files get shuffled around breaking peoples xcode and arduino setup. This tutorial is a modified version of Robert Carlsen’s. I found I had to make several modifications to get it working for me.
What You’ll Need:
- Arduino 0018
- Xcode 3.1 from Apple (I haven’t tested this on the newer 3.2. Let me know if it works for you)
- CrossPack for AVR (using version 20100115 for this tutorial)
- An Arduino (Using a freeduino with atmega168. I’ll give some specifics on using other version too)
- Modified version of Robert Carlsen’s ArduinoOnXcode template
Setup:
- Install xcode
- Install Arduino
- Install CrossPack. The tools are located at /usr/local/AVRMacPack
- Uncompress the ArduinoOnXcode project template. Move it to /Developer/Library/Xcode/Project Templates/Other/
- Open the Makefile in the AurdinoOnXcode folder. Edit MCU, ARDUINO, UPLOAD_RATE, and AVRDUDE_DIR if needed. The included values will work with an Arduino Diecimila/Duemilanove with an atmega168 chip. See below if you’re using and atmega328 or Arduino Mega.
- atmega328 use the following value:
- MCU atmega328
- UPLOAD_RATE 57600
- Arduino mega use:
- MCU atmega1280
- UPLOAD_RATE 57600
How to Use:
Create a new project in Xcode and select ‘Other’ then ‘ArduinoOnXcode’. It will ask for a new location to save the file.
Main.cpp is where your arduino code lives. Currently the project has a blinking LED sketch.
I’ve added the “clean all” button to my toolbar by right clicking on the toolbar and selecting “customize toolbar”. This is the button you’ll use to upload your sketch to the arduino. Once you’ve written your code just make sure that upload is selected in the dropdown menu and press “clean all”.
Head over to Robert Carlsen’s page for a few more handy tips.