Professional Documents
Culture Documents
Step 6: How this works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Step 7: Coding in C# (Windows) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
http://www.instructables.com/id/Controlling-an-Arduino-with-Cocoa/
File Downloads
Arduino Controller.zip (2 MB) [NOTE: When saving, if you see .tmp as the file ext, rename it to 'Arduino Controller.zip']
http://www.instructables.com/id/Controlling-an-Arduino-with-Cocoa/
-(IBAction)ledOff:(id)sender{ popen("echo o > /dev/tty.usbserial-A6006hmi", "r"); } Finishing The Coding: 12) Press 'Command + b' & press save all 13) Double click on MainWindow.xib. It is located under Resources 14) Interface Builder will open
http://www.instructables.com/id/Controlling-an-Arduino-with-Cocoa/
Image Notes 1. Press Command+n to get the new file dialog 2. Select Objective-C Class 3. Under Cocoa
Image Notes 1. Files added. Don't worry if it's not in the classes folder 2. In the file MainController.h add the code listed above after the '}' & before the line '@end'
Image Notes 1. Copy the code above to the section between '@implementation MainController' & '@end'
Image Notes 1. Add the code above between the brackets for both methods.
http://www.instructables.com/id/Controlling-an-Arduino-with-Cocoa/
Image Notes 1. Drag 2 buttons from the library pane to the window 2. Library Pane
Image Notes 1. Drag to here 2. Find the thing that looks like this. (NSObject)
http://www.instructables.com/id/Controlling-an-Arduino-with-Cocoa/
Image Notes 1. Go to the Identity inspector for the object you just created. (Command+6)
Image Notes 1. Go to the Connections inspector for the object you just created. (Command+5)
Image Notes 1. Click on the little round circle and drag to the correct button.
http://www.instructables.com/id/Controlling-an-Arduino-with-Cocoa/
Image Notes 1. Drag 2 buttons from the library pane to the window 2. Library Pane
Image Notes 1. Go to the Connections inspector for the object you just created. (Command+5)
http://www.instructables.com/id/Controlling-an-Arduino-with-Cocoa/
Image Notes 1. Drag to here 2. Find the thing that looks like this. (NSObject)
Image Notes 1. Go to the Identity inspector for the object you just created. (Command+6)
Image Notes 1. Click on the little round circle and drag to the correct button.
http://www.instructables.com/id/Controlling-an-Arduino-with-Cocoa/
http://www.instructables.com/id/Controlling-an-Arduino-with-Cocoa/
http://www.instructables.com/id/Controlling-an-Arduino-with-Cocoa/
http://www.instructables.com/id/Controlling-an-Arduino-with-Cocoa/
Related Instructables
Make Rocket Dock look EXACTLY like Mac OS X's Dock by MaconVista
Comments
18 comments Add Comment
melonfullofrainbowdinos says:
dude i love you
kevinfilteau says:
Oct 10, 2010. 9:50 PM REPLY 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. 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 find that too!
jsklein says:
Jun 22, 2010. 6:41 PM REPLY 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!
D5quar3 says:
does it matter what version OS X i have
adamohern says:
Feb 8, 2010. 11:11 AM REPLY Thanks for the great info! Is it just as easy to get info back from the Arduino to display on the screen? 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? Nov 9, 2009. 4:22 PM REPLY
beak90 says:
I wrote up a wiki page about how to do this a while ago located here: http://www.arduino.cc/playground/Interfacing/Cocoa It looks like its been changed a little since I wrote it, but I wrote up the part on using Popen().
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 "/dev/tty.usbserial-A6006hmi" thats in this code to the selected serial port in the Arduino program. Read my post for more info about this.
andrew101 says:
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...
i needed to change the com port to com4 because thats what my arduino uses, and when i press on or off the RX light goes on for a short time but it doesnt trigger... any ideas?
andrew101 says:
oh, nevermind, after a quick arduino reset it recognizes it. nice :)
Radiosity says:
Very nice! I'm going to try this next chance I get. Thanks!
http://www.instructables.com/id/Controlling-an-Arduino-with-Cocoa/
computergeek says:
Thanks. I'm glad you like it!
Radiosity says:
I just tried this and it worked great, but I just have one suggestion:
In your code you used the serial port "/dev/tty.usbserialA6006hmi", but this is dependent on which computer you are using. In my case I had to replace both instances of that with "/dev/tty.usbserialA4001KMJ" (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) Other than that great instructable and you have my vote!
guschabal says:
Thanks men! I write a similar program using WPF Application and your code for C#(Windows)! Thanks a lot!!
computergeek says:
Your welcome!
jeff-o says:
Oct 15, 2009. 10:37 AM REPLY Very neat. How would you go about building a standaloneapplication that interfaces to the Arduino, but doesn't require theArduino IDE to be running? Or is that the subject for a whole Instructable in itself?
computergeek says:
Oct 15, 2009. 5:11 PM REPLY 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.
jeff-o says:
Oct 16, 2009. 5:23 AM REPLY OS X. Not that I'm much of a programmer - I just thought it would be nice to build matching hardware and software. Could it be a driver issue? As in, a driver that is only loaded when the IDE is running?
computergeek says:
Oct 16, 2009. 11:24 AM REPLY It isn't a driver problem, but how the code works. If you run: "echo i > /dev/tty.usbserial-A6006hmi", "r" in terminal with the the arduino serial monitor open it will also work. All popen() does it run code in terminal. Here's an article on this topic . I do quite a bit of programming in cocoa, but not much with serial connections. So I'm fairly new to this.
jeff-o says:
Ah, well, maybe that will be fixed someday if enough people complain. ;)
http://www.instructables.com/id/Controlling-an-Arduino-with-Cocoa/