Multiple Analog Values from Arduino to Pure Data

Sending Analog Data From Arduino To Pure Data


Establishing a connection between the Arduino  and Pure Data is actually quite simple, and you don’t have to use one of the complicated (albeit very handy) libraries that work with the various Firmata.  With the [comport] object in Pd, you can receive data over serial, then parse that data if you are using multiple sensors.

First, you need to program the Arduino:

//Code to upload to Arduino

int val1;

int val2;

int val3;

void setup(){



void loop(){

val1 = analogRead(0);

val2 = analogRead(1);

val3 = analogRead(2);


val1 = map(val1, 0, 1023, 0, 100);

val2 = map(val2, 0, 1023, 101, 200);

val3 = map(val3, 0, 1023, 201,300);

//continue in the same fashion for more sensors




//DO NOT use Serial.println as the values will not show up in Pd correctly




//end of Arduino code

Then you have to parse the values that you get in Pd with the [split] object…









You can use the [devices] or [ports] messages to find the name and number of your desired port.  The two arguments to the [comport] object are 1. Port number, and 2. Baud rate.  Make sure the baud rate that you set in the Arduino code matches the one in the [comport] object!!!  (In this case it is 9600).


That should be it. Easy Peasy. Good luck. Enjoy.

Questions or comments: