Arduino and Carbon


I'm coding a Macintosh carbon app to communicate with my Arduino. I'm wondering if anybody can give me some direction on how to get my application to recognize my Arduino, which is connected via USB (serial).

I've found a tutorial on the Apple Developer website demonstrating how to communicate with USB devices, but it requires a product and vendor ID. Do these exist for the Arduino?

Thanks for any advice,


The USB drivers for Arduino (actually for the FTDI chip on the board) make the board show up as a virtual com port. So you should be looking for documentation on dealing with serial ports or com ports. Hope that helps.

Hi Jeremy, The Arduino doesn't appear as a USB device really. The USB-to-serial chip on the Arduino and the driver software you installed for it make Arduino look like a serial port. If you were writing straight C code (which I assume you are since Carbon is a set of C APIs), then you would just use the normal C open() file function on the path to the serial port (e.g. something like "/dev/tty.usbserial") and then the standard read(), write(), and close() functions on the file descriptor returned by open(). If you're unfamiliar with those C functions, just about any C reference guide will help. Speaking to serial ports is a little more complex than reading/writing files, but not much. Do a search on the net for C code that talks to modems, serial terminals, GPS receivers, or other things that use serial ports. You'll find lots of code.

If after all hunting around and it still doesn't make sense, let me know and I can post some simple command-line C examples that talk to Arduino.

Hey. Thanks for your answer.

I thought that it was more complicated than just reading and writing to files. Really figured that it was more complex (establishing a baud rate for connection speed, determining read and write events). I'll look into it this afternoon. I was also looking at Apple Developer documentation on reading a list of Serial devices, which only showed the modem and bluetooth (even though /dev/tty.usbserial was showing up in the Terminal). Anyway, I'd love to see an example or two.


I have a few xCode expamples for talking to the Arduino using Cocoa and C++. These examples should help you a bit.

stealthtransam, that's a great example.

For another take, using vanilla POSIX C (so should work on Linux and Windows-with-Cygwin), check out:

same principal as my examples. I just dumbed mine down for teaching reasons. Teach them the basics then short cut the code.

I have tried all the c examples I can find and I cannot get open() to work. It always returns with an error 'no such file or directory exists' even though I'm copying exactly the file path as listed when I do the following under Mac OsX Tiger console:

ls /dev/tty.*

I get back a few adresses but this is the one that s the arduino and open fails to see:


What am I doing wrong here? screen works, I can see the data coming in... but this damn open() just tells me my file doesnt exist?

I semi solved my problem, got it to work now. from advice in this thread:

I used Sudo to create an alias to my arduino.

sudo ln -s /dev/tty.usbserial-* /dev/tty.arduino

and then my c code successfully opened the /dev/tty.arduino

it makes me think that my serialized arduino's name is problematic. There is afterall a ? in the sring

For some reason the drivers from FTDI (which makes the USB-serial chip on the Arduino) assign names with non-ASCII characters to their devices. Don't ask me why.

or some reason the drivers from FTDI (which makes the USB-serial chip on the Arduino) assign names with non-ASCII characters to their devices. Don’t ask me why.

Because if the FTDI device has a serial number assigned the driver will use that serial number in the device special file name. I am particularly grateful for this feature, as I don’t have to worry about when and where a device gets enumerated when using multiple devices. If the device does not have a serial number the device special file gets a sequential name bsaed on when/where it was found (all other Mac rs232/usb drivers I’ve used operate this way exclusively, e.g. Keyspan).

I suspect there is a non-printable character in the serial number. ls /dev/tty.usb* | od -c may give you a clue as to wether or not I’m correct.

FTDI provides some tools that allow you to assign/reassign the serial number; unfortunately they are windows-only.


Yes, I know that, and I understand why you’d want each chip to have a serial number. It seems pretty silly to put non-printing characters in your serial number - or if you really need a binary serial number, at least convert it to text when you map the serial number to a device filename.

Agreed, binary characters in device special file names make no sense.

Does the FT232 come serialized? I know I've got a couple of rs232/usb adapters that do not (er, make that did not :) ) have serial numbers assigned.

Not sure if assigning a serial number is part of the Arduino manufacturing process, but technically (not sure about practically) it wouldn't be difficult to assign serial numbers, and even encode info about wheich release of arduino it was in the serial number. Don't suppose it would help windows folks, but Mac users would see it in the port name and linux users could find it with some system tools, and the arduino install process could even add some udev rules to make it show up in the device special file name for the linux folks.