0

I'm new to Arduino, and one thing I came across is this cool tool called Embedxcode, which basically allows you to compile and run sketches on the Arduino from Xcode instead of from the normal Arduino compiler.

The reason I'm using this is because I want the user to be able to do something on the Arduino (i.e. push a button) and the computer responds (i.e. call some function in Objective-C). Since as far as I know you can't do that from the Arduino compiler, I've decided to use Xcode because it can compile Objective-C and use the OSX SDK.

I got Embedxcode to work (the Arduino code compiles and uploads to the board fine), but I can't get Objective-C working. As in, I cannot create a new Objective-C class to pass data to without Xcode giving me errors (and no, renaming the C++ files to .mm did not work).

Does anybody know how to solve this? Or is there a better way to get Arduino to directly interact with OSX events?

3
  • 3
    embedXcode allows the use of the Xcode IDE for embedded development, but this doesn't include the OS X SDK or the OS X build toolchain. You are still using the AVR toolchain, but with Xcode in front to manage the project. That being said, you are limited to avr-gcc and avr-g++, no Objective-C. It is possible to pass data between C++ and Objective-C classes, but not in the context to which you are referring. Dec 23, 2012 at 7:53
  • Oooohhhh ok, I see. Is there any way to get around this? Do you have any other ideas of how I could do this? Dec 23, 2012 at 8:55
  • Moved response to answer section. Dec 23, 2012 at 19:59

2 Answers 2

1

embedXcode allows the use of the Xcode IDE for embedded development, but this doesn't include the OS X SDK or the OS X build toolchain. You are still using the AVR toolchain, but with Xcode in front to manage the project. That being said, you are limited to avr-gcc and avr-g++, no Objective-C. It is possible to pass data between C++ and Objective-C classes, but not in the context to which you are referring.

EDIT: If you really want to use Objective-C and Arduino, I suggest researching avr-gcc and Objective-C. According to the avr-gcc man page, Objective-C is supported. Although, getting this work will require meandering away from the cozy Arduino workspace.

0

It seems like you are misunderstanding the Arduino, and the microcontroller <-> PC relationship. The Arduino (and any microcontroller) is a small standalone computer running its own tiny operating system. So your question in light of that is: how do I get one computer to talk to another computer.

The IDE (XCode, the Arduino environment, etc.) has nothing to do with this. Those are just tools for writing and compiling code, and uploading it to the Arduino processor.

To connect any two computers, you have two options: through wires or through radio waves. The wired option is the easiest to implement and understand. You have two options here, direct USB connection and Ethernet. USB is the easiest to implement and understand and the barebones Arduino is capable of this. Ethernet would require addition hardware.

The wireless options would include Bluetooth, WiFi, XBee radio. These work well but are complicated to implement and require additional hardware.

So... I'd suggest you start with USB. There are many tutorials out there. On the OSX side you will need to write some software to communicate with the Arduino. This could be an app written in ObjectiveC or Java (e.g. using Processing) or Python, or any number of other programming languages. I'd suggest Processing as there are many Arduino <-> Processing tutorials on the web.

Key search terms for finding tutorials: Arduino serial port Processing

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.