Controlling An Arduino With Cocoa
Controlling An Arduino With Cocoa
Table of Contents
File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
http://www.instructables.com/id/Controlling-an-Arduino-with-Cocoa/
License: Attribution Non-commercial Share Alike (by-nc-sa)
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!
Notes:
- 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
File Downloads
Software:
- Xcode
- Arduino IDE
http://www.instructables.com/id/Controlling-an-Arduino-with-Cocoa/
step 2: Coding the app
Hopefully this makes sense. If you need help please ask any questions you have.
Note: If you don't want to code the app, or you don't have xcode, you can find the app in the source code download under: 'Build -> Debug'
-(IBAction)ledOn:(id)sender;
-(IBAction)ledOff:(id)sender;
-(IBAction)ledOn:(id)sender{
-(IBAction)ledOff:(id)sender{
http://www.instructables.com/id/Controlling-an-Arduino-with-Cocoa/
Image Notes Image Notes
1. Open Xcode 1. New Project Window
2. Select "Cocoa Application"
http://www.instructables.com/id/Controlling-an-Arduino-with-Cocoa/
Image Notes Image Notes
1. Copy the code above to the section between '@implementation 1. Add the code above between the brackets for both methods.
MainController' & '@end'
http://www.instructables.com/id/Controlling-an-Arduino-with-Cocoa/
Image Notes Image Notes
1. Resize the window 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. Press build and go
http://www.instructables.com/id/Controlling-an-Arduino-with-Cocoa/
Image Notes Image Notes
1. Double click on the buttons to rename them. 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. Click on the little round circle and drag to the correct button.
Image Notes
1. Press build and go
http://www.instructables.com/id/Controlling-an-Arduino-with-Cocoa/
step 5: Using, Notes, & More Ideas
To use the controller, make sure the serial monitor in the Arduino IDE is running. This is important!
To use the app you can either press build & go in xcode or find the app in the xcode project under:
'Build -> Debug'
Notes:
- This will only work on Mac OS X
- The Source code is attached on the first step.
- If you don't want to code the app, or you don't have xcode, you can find the app in the source code under: 'Build -> Debug'
Ideas:
- Make it so there are two buttons that control a servo's rotation
- Make a small piano
- Make a physical output for your mac
- Make a pan & tilt webcam
For the Arduino to receive the signal from the cocoa app the serial monitor in the Arduino IDE needs to be open.
If this doesn't make sense it's fine. This is kind of a reference if you want to expand the functionality of the program.
http://www.instructables.com/id/Controlling-an-Arduino-with-Cocoa/
http://www.instructables.com/id/Controlling-an-Arduino-with-Cocoa/
Related Instructables
How to make
Arduino Led Advanced Windows Vista DIY Apple Arduino XMAS
Mac Dice by Truffle-Making: Or XP Look Like Remote Shield hitcounter by
OS Foot Switch Watts-your- Create an Davuzz11 Slabbed Mac Os X for the Arduino alex_weber
from a Guitar consumption? - Applescript/Arduino Ganache and Without Putting by computergeek
Amp Pedal. by Wireless Power Alert flag. by Multi-Layer Your Computer
aymans Meter by aarone Truffles by At Risk by
mcloke74 Mongpoovian laxdude31
Advertisements
Comments
14 comments Add Comment
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.
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?
http://www.instructables.com/id/Controlling-an-Arduino-with-Cocoa/
computergeek says: Oct 19, 2009. 7:22 PM REPLY
Thanks. I'm glad you like it!
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)
Thanks a lot!!
http://www.instructables.com/id/Controlling-an-Arduino-with-Cocoa/