Pure Data to Arduino Over Serial

Contents:

A basic example of getting the Arduino to make music using Pure Data.
void setup() {
 Serial.begin(9600);
}

void loop() {
 for (int i=0; i<255; i++) {
 Serial.write(i);
 delay(100);
 }
 for (int i=255; i>0; i--) {
 Serial.write(i);
 delay(100);
 }
}

#N canvas 644 73 523 614 10;
#X obj 186 309 dac~;
#X obj 110 182 r left;
#X obj 298 180 r right;
#X obj 36 150 osc~;
#X obj 80 151 osc~;
#X obj 39 194 *~ 0.2;
#X obj 235 181 *~ 0.2;
#X obj 266 227 *~ 1;
#X obj 90 226 *~ 1;
#X obj 35 47 comport 9600;
#X msg 36 17 devices;
#X msg 95 19 open 2;
#X floatatom 35 70 5 0 0 0 - - -;
#X obj 35 102 * 10;
#X obj 75 103 * 20;
#X connect 1 0 8 1;
#X connect 2 0 7 1;
#X connect 3 0 5 0;
#X connect 4 0 6 0;
#X connect 5 0 8 0;
#X connect 6 0 7 0;
#X connect 7 0 0 1;
#X connect 8 0 0 0;
#X connect 9 0 12 0;
#X connect 10 0 9 0;
#X connect 11 0 9 0;
#X connect 12 0 13 0;
#X connect 12 0 14 0;
#X connect 13 0 3 0;
#X connect 14 0 4 0;
A nice feature of Pd is that all the patches are in a simple text format.

To Get this Example Working:

          pd

You should see output of the comport changing, and should hear a rising and falling tone.

Pure Data to Arduino over serial in Action - Shown with "Hello Arduino" Board"