Pd and Arduino (or whatever you call it.)

By: coldham

2009-06-01 18:57:28

I never blog! But I've been integrating AVR's with Pd for a few years now, and It's time to share my technique, such as it is.

I use the AVR as a sensor interface, and as a controller for music. It's mostly reading values from the "digital" pins, which are generally hooked up to a button or switch, and reading voltages from "analog" pins, which are hooked up to a knob or slider or other form of voltage divider. There's a sketch in the .zip below called SimpleSend.pde, which does this, and another called Send_median3.pde that does the same but with a fancy median filter for eliminating outliers.

The next step is to send this info to the serial port and read it in Pd. There is an external, [comport] (included with extended), which is made for reading serial in Pd, but the trick is to convert the bytes coming in to numbers and symbols that are useful in Pd. I've used tof's [ascii2pd] abstraction in my patches, and it works great and is very flexible and useful and all that, but on one of my machines it wouldn't work because it depends on [coll] (from cyclone) which wouldn't create on that machine. I built an abstraction that is not very flexible, but has no dependencies. It's included in the .zip below, and is called SimpleReceive.pd. Another patch using [ascii2pd] is in there too, it's called SimplerReceive.pd.

If you want to build a controller, this should get you on your way. Of course, there is also the topic of sending from Pd to the AVR, and some other tools like firmata, and some interesting hardware hacks that we are thinking of for a future dorkbot workshop!


Back to archive index