Ascii to Number in Max/MSP

This patch receives an ASCII-encoded decimal string that ends with a linefeed and carriage return in the serial port, and converts it to a number. A Wiring/Arduino program to send data to it follows. It’s based on an example by Jamie Allen.

To use the patch, copy the text and paste it into a new max patch window.

Thanks to David Mellis and Jamie Allen for the collaboration. These patches were written for a one-day Arduino workshop at NIME 07 hosted by the three of us. The Arduino program comes from the Arduino example files, by David Mellis.


asciitonumber.png

max v2;
#N vpatcher 275 262 515 549;
#P window setfont "Sans Serif" 9.;
#P number 108 244 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 108 223 62 196617 fromsymbol;
#B color 5;
#P newex 108 200 40 196617 itoa;
#B color 5;
#P newex 108 177 55 196617 zl group 4;
#P newex 52 139 67 196617 select 10 13;
#P toggle 52 46 15 0;
#P newex 52 68 52 196617 metro 10;
#P message 87 90 32 196617 print;
#P newex 52 115 71 196617 serial a 9600;
#P connect 3 0 2 0;
#P fasten 1 0 0 0 92 110 57 110;
#P connect 2 0 0 0;
#P connect 0 0 4 0;
#P fasten 4 2 5 0 113 180 113 180;
#P fasten 4 0 5 0 57 168 113 168;
#P connect 5 0 6 0;
#P connect 6 0 7 0;
#P connect 7 0 8 0;
#P pop;

Wiring/Arduino program to send data:

void setup()
{
  Serial.begin(9600);
}void loop()
{
  int val = analogRead(0);
  Serial.println(val, DEC);
  delay(100);
}
This entry was posted in arduino/wiring, Max/MSP. Bookmark the permalink.

Comments are closed.