How to send RGB value from Arduino to Max/Msp by specific cmd.value?y

I want the Arduino to send RGB values to Max/Msp if cmd is 'pwr'. If cmd is 'stop', the Arduino stops sending RGB values. Is that possible???

Do you have any better idea to get RGB values or stop getting RGB values by remote controller? By the way, I use the TCS3200 to get RGB values.

By any chance, could you please help me? I really need help with my final project!

This is the code.

#define S0 6
#define S1 7
#define S2 8
#define S3 9
#define sensorOut 10
int redF = 0; int greenF = 0; int blueF = 0;
int redC = 0; int greenC = 0; int blueC = 0;

#include<IRremote.h>

int IRpin=11;
IRrecv IR(IRpin);
decode_results cmd;
String myCom;

int speedPin=5;
int dir1=4;
int dir2=3;
int mSpeed=255;

void setup()
{

  setupTurntable ();
  setupColor ();
  
}
  


void setupTurntable (){

  Serial.begin(9600);
  IR.enableIRIn();

  pinMode(speedPin,OUTPUT);
  pinMode(dir1,OUTPUT);
  pinMode(dir2,OUTPUT);
  digitalWrite(dir1,HIGH);
  digitalWrite(dir2,LOW);
}

void setupColor (){
  pinMode(S0, OUTPUT); 
  pinMode(S1, OUTPUT); 
  pinMode(S2, OUTPUT);
  pinMode(S3, OUTPUT); 
  pinMode(sensorOut, INPUT); 
  digitalWrite(S0,HIGH); 
  digitalWrite(S1,LOW); 
} 

void loop(){

  loopTurntable();
  loopColor();
  
}



void loopTurntable(){
  
  if (IR.decode(&cmd) == 0) return;{
}


IR.resume();


if (cmd.value==0xFFA25D){
  myCom="pwr";
  Serial.println(myCom);
}
  
 if (cmd.value==0xFFE21D){
  myCom="stop";
  Serial.println(myCom);
}
 

 if (cmd.value==0xFFE01F){
  myCom="dn";
  Serial.println(myCom);
}
 
 if (cmd.value==0xFF906F){
  myCom="up";
  Serial.println(myCom);
}
 
 
if(myCom=="pwr"){
  digitalWrite(dir1,LOW);
  digitalWrite(dir2,HIGH);
  analogWrite(speedPin,255);
}


if(myCom=="stop"){
  digitalWrite(dir1,LOW);
  digitalWrite(dir2,HIGH);
  analogWrite(speedPin,0);
  
}
if(myCom=="up"){
  mSpeed=mSpeed+15;
  if(mSpeed>255){
    mSpeed=255;
}
if(myCom=="dn"){
  mSpeed=mSpeed-15;
  if(mSpeed<0){
    mSpeed=0;
}

  
analogWrite(speedPin,mSpeed);
} 
 }
}

void loopColor(){
  
  digitalWrite(S2,LOW); 
  digitalWrite(S3,LOW);
  redF = pulseIn(sensorOut, LOW); 
  redC = map(redF, 70,120, 255,0);
  delay(80);
  
  digitalWrite(S2,HIGH); 
  digitalWrite(S3,HIGH);
  greenF = pulseIn(sensorOut, LOW); 
  greenC = map(greenF, 100, 190, 255, 0);
  delay(80);
 
  digitalWrite(S2,LOW); 
  digitalWrite(S3,HIGH);
  blueF = pulseIn(sensorOut, LOW); 
  blueC = map(blueF, 38, 84, 255, 0);
  delay(80);
  
Serial.print(redC); Serial.print(" "); 
  Serial.print(greenC); Serial.print(" "); 
  Serial.println(blueC); Serial.print("");
  
  
}

What is a Max/Msp ?

I think this link could tell you what is Max better.

if Max is software, then you will need to use an external program to get data from the Arduino and translate that into a command to send to the Max software

Thank your for your advice!

I can get data from Arduino to Max. But I can't control Arduino to start sending RGB value or stop sending RGB value to Max.

I asked someone if I can start or stop getting data in Max. He said "you should rather do that in Arduino and send RGB values only if cmd is pwr."

So I think maybe I can do it in Arduino.