Serial Data from Arduino to MAX
Hey everyone,
I am a beginner to MAX. Currently working on a project that receives light intensity levels as inputs from 12 photoresistors (light sensors) on arduino (through a 16-channel analog multiplexer) and sends it to max msp to change those values to sounds as outputs.
However, I cannot get the accurate values on MAX. I wonder if I'm missing an object that is required when multiplexer is used.
Attached is my patch.
Any help is appreciated. Thank you!!!
I think that sel 52 should be 13...
Only sel 13 or sel 13 10? The thing is data seems to change all the time in the max console. I am trying to figure out how to convert the data back to exact value that I see in arduino
10 and 13 (ASCII dec) are line feed and carriage return
Arduino usually sends 10 when println is used.
But ... your arduino code is unknown, so one can't say at all if you are sending new line messages
12 sensors sending fast data would quickly fill zl group to output captured list when default list length is
received.
Which is 256
zl group 1000 makes no sense,for larger than 256 , you must set additional argument.
also few comments in that patch show that whoever did them has no real knowledge
of this all
I see. I tried previously with sel 10 13 for less sensors and at times, I had to change the values that's why I assumed I had to change it again. Attaching my arduino code below.
I have been honestly watching videos, reading forums and taking stuff from wherever I see.
What can I add additionally?
//16 channels analog multiplexer
//Pinout
// S0 -> Arduino Digital 8
// S1 -> Arduino Digital 9
// S2 -> Arduino Digital 10
// S3 -> Arduino Digital 11
// E -> GND
// Z -> Arduino Analog A0
// VEE/ GND -> Arduino GND
// VCC -> Arduino + 5V
// Y0 to Y15 -> Analog Extended Pins - Y0-Y11
const byte sensePin = A0; //Analog Pin connected to Arduino
void setup()
{
DDRB = 255;
Serial.begin(9600);
}
void loop()
{
int valY [12];
for (byte i = 0; i < 12; i++) {
PORTB = i;
(void)analogRead(sensePin); // discard the first reading
valY [i] = analogRead(sensePin);
}
for (byte i = 0; i < 12; i++) {
Serial.print(valY [i]);
Serial.print(" "); //to seperate each value
}
Serial.println(); // Send ASCII CR & LF (13 & 10) to mark end of message
delay(800); //delay to see values better, snaller for last version
}
So, the reason you have to use sel 10 13 is because arduino sends them through the serial port (13 = return character //// 10 = newline character) and you dont want them to pass through the right most output of the sel object because they will mess up your value-list. Can you please print the serial output on the max console and send us a screenshot. In order to work you should have the following
13
10
value1
value2
...
value12
13
10
Also i think that you can loose the print" " and then the println. Just type Serial.println(valY [i]);and close the loop.
you are sending println at the end so this should work

It worked thank you all for the help