Thing 21: Chapter 7 (4 of 4): Serial in PureData-extended.

Serial in PD-Extended (not Max/MSP) P177

In class I wanted to demonstrate some of the ways that arduino serial works so I had my students wire up a pot and walk through sending the values through the serial port. Then we scaled the 10 bit number to a byte and sent it as hex and finally we sent it to pure data.

The sketch we started with was the analog read example sketch.

The sketch we wound up with was this.

  Reads an analog input on pin 0, converts it to voltage, and prints the result to the serial monitor.
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.

 This example code is in the public domain.

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  int voltage = map(sensorValue, 0,1023, 0, 255);
  // print out the value you read:
  //Serial.println(voltage, HEX);

Note: The above sketch will crash (lock up your mac) the arduino serial monitor. 

Then we fed it to the comport object in pd-extended.



About feurig

My name is Donald Davis, I make Suspect Devices. (

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: