Pd [puredata], OSX and Arduino

If there is anyone interested in getting the Arduino talking directly to Pd on a Mac (OSX Tiger) then the following may prove usefull. Sorry for my simplistic description of the proceedure.

The first stage is obvious - install all the software from the Arduino site ie 'Arduino 0003' and the USB serial driver. Now download the 'Pd-0.38.4-extended-RC7' from Hans-Christoph Steiner's website.


Follow his really simple install instructions. This version of Pd is packaged as an app, so it is ultra easy to install. Don't forget to put the 'org.puredata.pd.plist' file in your '~/Library/Preferences' directory as it will load all the externs when Pd opens.

The next thing to do is find out the path of your Arduino. To do this you need to plug the Arduino in to the USB port. Open the 'Arduino 0003' application and goto the 'Tools/Serial Port' menu and look for a device path that includes 'tty.' but NOT 'modem'. My path is: '/dev/tty.usbserial-0B2'. Write this path down as you'll need it in Pd. In order to test communication I ammended (simplified) the 'serial_write_basic' file. It says 'hello' every 5 seconds. Here is the code.

/* Serial Ping say hello every 5 seconds */

int val = 0; // variable to store the data from the serial port

void setup() { beginSerial(9600); // connect to the serial port }

void loop () { printString("hello"); printNewline(); delay(5000); // convenient to use delays when sending stuff back to the comp. } // end

Also take a note of the baud rate (9600) as we need that info in Pd too. Upload this code onto your Arduino. You can quit the Arduino app and leave the board plugged in and running it's futile attempts to make friends.

The real business is setting up Pd to receive the hello message. We do this with the 'comport' object, written by Winfried Ritsch. If you know Pd then insert an object and enter 'comport 1 9600' into it's body. The '1' is the port number and the '9600' the baud rate. The comport object needs a message to set the path to the Arduino. Make a message with 'devicename /dev/tty.usbserial-0B2' and connect this to the comport object inlet (upper left). You will probably see an error message in the Pd window. Ignor it. Save your patch, click the message to send it to the comport object and then close the patch. Reopen the patch and it should start receiving the data from the Arduino. The message comes in as character bytes, so 'hello' is received as - 104,101,108,108,110,10 (return).

I know this is the 'hello world' tutorial but Pd is open source, like Arduino, and fun to be with.

Now to do something interesting. I'll make a .zip of the info and post it somewhere if anyone needs it.


thanks for the report, if you had taken a look at www.arduino.ws, you would have found a package that we wrote together with Hans :wink: (he is int hte business since last Novemeber).

Thanks for the report, I am sure it will be very useful to many people.


Aaaahh. I never saw that. I was looking forward so much to working it out for myself :)

Hello da'n

I set up my pd to receive the data from my arduino. I tryied with a lot of sensors like a potentiometer, a photocell, a temperature sensor etc and it works.

The thing that [ch305] already not understood is that for example with the potentiometer [ch305] receive numbers between 0 and 1023 on my arduino Serial Monitor.

Nearby when [ch305] make the connection with pd with the comport object, I receive outputs between 10 and 50 or something like that (the numbers are changing so fast that [ch305] can not read them but its oscilating between something like 10 and 50).

Do you have an idea for how can [ch305] modulate this numbers?