MUX Shield and MAX/MSP?

Hi everyone,

does anybody in here have some experience with getting the MUX Shield (which I recently purchased from sparkfun) to talk to MAX/MSP?

I got the regular analog ins succesfully communicating with MAX - using the serial object and zl group and then unpacking (splitting) the various numbers but it's not working the same way with the MUX shield.

Anybody with experience?

I want to make a controllerbox (like a midi controller) with the MUX and could be nice to get it all mapped out in MAX/MSP.

Best regards,

Okay, so I got this sort of figured out by myself - though I'm not sure if it's the easiest way to do this. :roll_eyes:
I replaced the code that went with the MUX Shield, from Mayhew Labs, so things will be easier for MAX to route around.
My arduino-code (for the MUX Shield setup) is as follows:

void setup() {
pinMode(5, OUTPUT);
pinMode(4, OUTPUT);
pinMode(3, OUTPUT);
pinMode(2, OUTPUT);


void loop() {
int val = getSensorValue(0);
Serial.print( "0 " );
Serial.println( val );
val = getSensorValue(1);
Serial.print( "1 " );
Serial.println( val );

int getSensorValue( int sensor ) {
int muxId = sensor >> 4;
int inputId = sensor % 16;

digitalWrite(5, (inputId&15)>>3);
digitalWrite(4, (inputId&7)>>2);
digitalWrite(3, (inputId&3)>>1);
digitalWrite(2, (inputId&1));

return analogRead(muxId);

So the getSensorValue() function will fetch the signal from one of the 0-47 channels.
What I'm concerned about, is the latency if all 48 inputs needs to be read in this way.
The code from Mayhew Labs is sort of packing the values for each mux-IC and I guess it'll be much more efficient that way.

Inputs highly appreciated!


And, for anyone interested, here's my max patch - it works properly.
The code to the right is just a sample, for the 5 inputs shown below you just keep on adding
val = getSensorValue(1);

  • Serial.print( "1 " );*
  • Serial.println( val );*
    with the value in the getSensorValue being the analog in on the mux shield you are reading from and the integer in the Serial.print(""); being what number to associate the input with in MAX/MSP.
    Typing a number followed by a space to be printed, makes it all piece of cake for max to route the values associated with the identifier.

hei paleorama,
I am looking for the Mux2Max patch and found your post!
Did you use the Maxuino patch to get the data from your inputs or just the patch shown in the screenshot? Can you paste the code please?