No I'm not talking about controlling an Arduino with a chocolate bar or cocoa powder. I'm talking about the programming language, Objective-C. So what is cocoa? Cocoa is a set of frameworks written in the programming language of Objective-C for Mac OS X. No there isn't a test at the steps so you don't have to worry about remembering all of this. Just know that when I talk about cocoa I'm not trying to make you hungry.

 Now I understand some people are probably wondering why you would want to use Cocoa instead of Processing, the reason I have is: if you use Cocoa over Processing you can have a full Computer Application(e.g. Safari, Mail, iCal) that can have a physical output. (e.g. Lights, motors, servos)

So Have Fun, Work hard, & Play nice! Please ask any questions you have!

- This will only work for Mac OS X & Windows
- The source code is attached below.
- If you don't want to code the app, or you don't have xcode, you can find the app for OS X in the source below under: 'Build -> Debug'
- The instructions for Windows are in step 7

Step 1: Stuff you need:

- Arduino
- A-B USB Cable
- Computer with Mac OS X

- Xcode
- Arduino IDE
MARK ! So cool.
sh: /dev/tty.usbmodemfd131: Permission denied appear in Xcode 5.0.2 <br>Can't turn on the LED. Can anyone help ? Please
Hello, nice tutorial! <br> <br>I have a problem here, when building the code. When I press command + b, i get the &quot;Expected specifier-qualifier-list before '-' token&quot; error on the lines <br> <br> <br>-(IBAction)ledOn:(id)sender; <br>-(IBAction)ledOff:(id)sender; <br> <br>of manicontroller.h file. <br> <br>Im using Xcode 3.2.6 on a SLeopard 10.6.8 <br> <br>Do you people have a clue on this problem?? <br> <br>Thank you very much
Make sure the IBActions are not in parentheses
Thank you, i will try!
Hello, well i have a problem, when I click in the button ON it doesnt turn on the led, so i think the problem is in the Baud because it need to be in 9600, so I want to know if you know how to change the Baud in the popen() function.
I'm trying to modify this for picaxe (using the same code for cocoa), and I keep getting an error message in Xcode: sh: /dev/tty.usbserial-000013FD: Resource busy. Any idea what I should do?
Very informative. I find &quot;Processing&quot; very interesting in interfacing and controlling the serial port of an Arduino by Mac.
I pass through your article when I was seeking a simple way to communicate with my Arduino from the Internet. After many days of unsecessful reseach, I decided to make one application of my own.<br> <br> So I made up a Mac application that can relay strings send from the Internet to a connected serial device and vice versa. I now think I must share because this app is very useful for me. So maybe you'll <a href="http://playwithmyled.com/insek/">find that too</a>!
interesting, I'm sure I'll find a use for this. Thanks
Greatly appreciated.<br>My Arduino is in the post, can't wait to get started.
dude i love you
Thanks! It worked great but I had to change the serial port number from the one you gave (A6006hmi) to my Arduino's own serial port number. It took my a while so maybe you could write in that you have to use your serial port number and not the one you give. Thanks again!
&nbsp;does it matter what version OS X i have
Thanks for the great info!&nbsp;Is it just as easy to get info back from the Arduino to display on the screen?&nbsp;I want to make a bicycle computer that displays all of its info in Mac OS X... does that seem like something that would be relatively easy using this method?<br />
I wrote up a wiki page about how to do this a while ago located here: <a href="http://www.arduino.cc/playground/Interfacing/Cocoa">http://www.arduino.cc/playground/Interfacing/Cocoa</a><br /> It looks like its been changed a little since I wrote it, but I wrote up the part on using Popen().<br /> <br /> Also, you have to change the part in the code after the tty.usbserial to whatever port your Arduino is on. So you have to look in the Arduino program under Tools/Serial Port then replace the &quot;/dev/tty.usbserial-A6006hmi&quot; thats in this code to the selected serial port in the Arduino program. Read my post for more info about this.<br />
cool code, only thing is, when i use the serial monitor to send an i or o to the arduino it works, but the program wont...<br /> <br /> i needed to change the com port to com4 because thats what my arduino uses, and when i press on or off the RX&nbsp;light goes on for a short time but it doesnt trigger...<br /> <br /> any ideas?<br />
oh, nevermind, after a quick arduino reset it recognizes it. nice :)<br />
&nbsp;&nbsp;Very nice! I'm going to try this next chance I get. Thanks!
&nbsp;Thanks. I'm glad you like it!
I just tried this and it worked great, but I just have one suggestion:<br /> <br /> In your code you used the serial port &quot;/dev/tty.usbserialA6006hmi&quot;, but this is dependent on which computer you are using. In my case I had to replace both instances of that with &quot;/dev/tty.usbserialA4001KMJ&quot; (which was the port I had selected in the Arduino IDE) in order for my application to properly send data to my arduino. I suggest to add a step in which you find out which serial port you are using and add it into the code. (Just to prevent any confusion for somebody else reading this instructable)<br /> <br /> Other than that great instructable and you have my vote!<br />
Thanks men! I write a similar program using WPF Application and your code for C#(Windows)!<br /> <br /> Thanks a lot!!
&nbsp;Your welcome!
Very neat.&nbsp; How would you go about building a standaloneapplication that interfaces to the Arduino, but doesn't require theArduino IDE to be running?<br /><br />Or is that the subject for a whole Instructable in itself?<br />
&nbsp;I'm glad you like it! Are you using Mac OS X or Windows? If youhave Windows you don't need it open. But for some reason the Arduino IDEneeds to be open in Mac OS X. It might be possible, but I have no clue.
OS X.&nbsp; Not that I'm much of a programmer - I just thought it would be nice to build matching hardware and software.&nbsp; Could it be a driver issue?&nbsp; As in, a driver that is only loaded when the IDE is running?<br />
&nbsp;It isn't a driver problem, but how the code works. If you run:<br /> &quot;echo i &gt; /dev/tty.usbserial-A6006hmi&quot;, &quot;r&quot; <br /> in terminal with the the arduino serial monitor open it will also work. All popen() does it run code in terminal. <a href="http://www.arduino.cc/playground/Interfacing/Cocoa">Here's an article on this topic</a>. I do quite a bit of programming in cocoa, but not much with serial connections. So I'm fairly new to this.
Ah, well, maybe that will be fixed someday if enough people complain.&nbsp; ;)<br />

About This Instructable


69 favorites


More by computergeek: DIY Apple Remote (Slideshow for the instructable) DIY Apple Remote Shield for the Arduino Simple 2-way motor control for the arduino
Add instructable to: