Arduino and Max7 - Serial Data (Separating data to be read in Max)

Hi folks,

I’m new to Arduino so please excuse me for asking what is probably a really basic question.

I’ve got an Arduino patch which in Serial Monitor gives me a list of data from a number of sensors and other controls (1k potentiometers, LDRs and an RGB sensor).

The problem I’m having is that in Max, when using the unpack object, I’m getting all values across all outputs, rather than one stream of data per output.

I’ve used the MaxPatch before with another sensor-based device and it worked fine, so I’m wondering if perhaps the issue lies in the Arduino code I’ve botched together. I’ve followed the same principles as my previous, simpler effort which used Piezo’s rather than LDRs.

Can anyone offer any pointers, or tell me if there is an obvious reason why this code might not be behaving as I had expected with my Max Patch?

Thanks all!

int sensorPin1 = A5; // 1k Potentiometer
int sensorVal1 = 0; 
int sensorPin2 = A6; // LDR
int sensorVal2 = 0; 
int sensorPin3 = A7; // LDR
int sensorVal3 = 0; 
int sensorPin4 = A8; // LDR
int sensorVal4 = 0; 
int sensorPin5 = A9; // LDR
int sensorVal5 = 0; 
int sensorPin6 = A10; // LDR
int sensorVal6 = 0; 
int sensorPin7 = A11; // LDR
int sensorVal7 = 0;
int sensorPin8 = A12; // LDR
int sensorVal8 = 0;
int sensorPin9 = A13; // LDR
int sensorVal9 = 0;
int sensorPin10 = A14; // LDR
int sensorVal10 = 0;
int sensorPin11 = A15; // LDR
int sensorVal11 = 0;

#include <Wire.h>
#include <SparkFun_APDS9960.h>

SparkFun_APDS9960 apds = SparkFun_APDS9960();
uint16_t ambient_light = 0;
uint16_t red_light = 0;
uint16_t green_light = 0;
uint16_t blue_light = 0;

void setup() //
{

  
  Serial.begin(115200); 

    if ( apds.init() ) {
    Serial.println(F("GO"));
  } else {
    Serial.println(F("FAILED"));
  }
  
  if ( apds.enableLightSensor(false) ) {
    Serial.println(F("YEP"));
  } else {
    Serial.println(F("NOPE"));
  }
  
  delay(500);
}
void loop () 
{
  
  
  sensorVal1 = analogRead(sensorPin1); // 1k Potentiometer
  sensorVal2 = analogRead(sensorPin2); // LDR
  sensorVal3 = analogRead(sensorPin3); // LDR
  sensorVal4 = analogRead(sensorPin4); // LDR
  sensorVal5 = analogRead(sensorPin5); // LDR
  sensorVal6 = analogRead(sensorPin6); // LDR
  sensorVal7 = analogRead(sensorPin7); // LDR
  sensorVal8 = analogRead(sensorPin8); // LDR
  sensorVal9 = analogRead(sensorPin9); // LDR
  sensorVal10 = analogRead(sensorPin10); // LDR
  sensorVal11 = analogRead(sensorPin11); // LDR
  


 

  if (  !apds.readAmbientLight(ambient_light) ||
        !apds.readRedLight(red_light) ||
        !apds.readGreenLight(green_light) ||
        !apds.readBlueLight(blue_light) ) {
    Serial.println("Error reading light values");
  } else {
    Serial.print(" "); 
    Serial.print(ambient_light);
    Serial.print(" "); 
    Serial.print(red_light);
    Serial.print(" "); 
    Serial.print(green_light);
    Serial.print(" "); 
    Serial.print(blue_light);
    Serial.print(" "); 
    Serial.print(sensorVal1); // 1k Potentiometer
    Serial.print(" "); 
    Serial.print(sensorVal4); // LDR
    Serial.print(" "); 
    Serial.print(sensorVal5); // LDR
    Serial.print(" "); 
    Serial.print(sensorVal6); // LDR
    Serial.print(" "); 
    Serial.print(sensorVal7); // LDR
    Serial.print(" "); 
    Serial.print(sensorVal8); // LDR
    Serial.print(" "); 
    Serial.print(sensorVal9); // LDR
    Serial.print(" "); 
    Serial.print(sensorVal10); // LDR
    Serial.print(" "); 
    Serial.print(sensorVal11); // LDR
    Serial.print(" "); 
  }
  
  Serial.println(); 
  delay(10); 
}

what is MaxPatch?

Ah yeah, sorry - it wouldn't allow me to attach it last time.

----------begin_max5_patcher----------
1058.3oc4Y01aaBCD9yI+JP74rH+B1F1ekooJRhSFc.NBLcoqp+2mwFRnoAiWfVUITkRx43fetm6Ee20WVtvei3Duz266d+vawhWVtXgdo5EVzHuvOK9z1z3R817y4+Qr4Q+UluRxOI0KWxS8f.OHt8aDUxTtT97Qt4o6uIN+f+pKu668ylsdLVt8WI4GdnfuUZ1MJDsFrxKBulrxiDU+YjZky+jjc5SUgjugZOw7prjb0YpwItYwR4yoZD32YaFrY1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GSOXwGO9Dunr4j03U0C5iBco+rUZwjbindZg9E7mRZ2efdk3BUWkRUKkUElF.OEZFvpelP0DQdURSeDpS90k+Cfely8D
-----------end_max5_patcher-----------

I still have no clue what that is.

Oh, I thought you were asking to see it.

It's a MaxMSP patch - seemed like this might be the best forum for it.

Metatarsals:
Oh, I thought you were asking to see it.

It's a MaxMSP patch - seemed like this might be the best forum for it.

I had to Google MaxMSP to know what it is.

If you want help make sure that you provide all the information and don't assume others know whatever MaxMSP is! Sheesh.

And I have no clue what the max5 patcher is suppose to be or suppose to be for.

Hopefully someone who is more knowledgeable can give you the help you need.
I don't have the time to waste on chasing this.

.

If you look at the name of this particular section of the forum, MaxMSP is in the title. I also wrote Max in the title of my post, and the content references it. Anyone who knows what Max is, will know what I'm talking about. I'm not sure what's so cryptic about that. If it wasn't clear from that, you were never going to be able to help.

I apologise that I didn't explain it to the level that you personally understood it, but don't act like I'm wasting your time when you've just made it very clear that you wouldn't have been able to help anyway.

If you've had to google it, you've wasted your own time.

Metatarsals:
If you look at the name of this particular section of the forum, MaxMSP is in the title.

I can't see it.

If you've had to google it, you've wasted your own time.

That is not a nice attitude.

Lot's of people may be well able to help even though (like me) they know nothing about MaxMSP because lots of computer problems are much the same when you look under the hood. Serial data is serial data regardless of what produces it or uses it. Petrol (gasoline) is much the same whether it drives a Rolls Royce saloon or an off-road motor-bike.

So maybe have another think and, if you really want help, provide a full explanation of the problem.

...R

Let's say I have no idea what python is.

And you post a question about python. And I reply saying I had to google Python just to know what it is and that's your fault, even though there is a header in the title of the forum that says Python...

That makes me a dick, no?

That's literally what has happened here. Just because I'm asking for help. doesn't mean I have to put up with people's bullshit.

Metatarsals:
That's literally what has happened here. Just because I'm asking for help. doesn't mean I have to put up with people's bullshit.

Yet another Forum user who prefers a grievance to a solution.

We should start a "Wall of Grievance" to sit alongside the Wall of Shame

...R

Losers. One and all.

Metatarsals:
Losers. One and all.

I am going to quote you so that the next time you ever post a question here, we will simply post a link to this!

Don't let the door hit your butt on your way out.

:slight_smile:

.