too few arguments to function 'void setColor(int, int, int)' When I put "c" inside setColor(c);

it tells me:

error: too few arguments to function 'void setColor(int, int, int)'.


I understand that I should put 3 arguments. What I don't understand is that the serial is correctly displaying the 3 arguments (255, 000, 000) so why it keeps telling me this error. What am I doing wrong ?

int rPin = 11;
int gPin = 9;
int bPin = 10;

void setup() {
    Serial.begin(9600);
    pinMode(rPin, OUTPUT);
    pinMode(gPin, OUTPUT);
    pinMode(bPin, OUTPUT);
}

void loop() {
    if (Serial.available() &gt; 0) {
            delay(100);
            while (Serial.available() &gt; 0) {
                char c = Serial.read(); // serial will display an rgb code, for exemple: 255, 000, 000 (red color) 
                setColor(c);
            }
        }
}

void setColor(int red, int green, int blue) {
    analogWrite(rPin, red);
    analogWrite(gPin, green);
    analogWrite(bPin, blue);
}
In the context of C/C++, the type char refers to a primitive type that can contain exactly one byte of information, or 8 bits if you like.


  the serial is correctly displaying the 3 arguments (255, 000, 000) 


In your question, you do not specify how you verify that this is indeed the information that returns from Serial.read. Serial.read returns one byte, which can be cast or parsed to an Integer but cannot be interpreted as the triplet (255,000,000) in no way. If you keep calling it repeatedly, however, as long as there is data (meaning that the result is greater than -1 or Serial.available returns a number greater than 0) - you can accumulate the characters to a meaningful string, which you can later split to three different int values. For example:

String incomingData = "";

void loop() 
{
    if (Serial.available() &gt; 0) {
         delay(100);
         while (Serial.available() &gt; 0) {
             char c = Serial.read(); 
             incomingData.concat(c);
         }

         // now, the string incomingData will contain "255,000,000" which you can split into 3 different integers and send to setColor. 
         // so, assuming the format "ddd,ddd,ddd":

         int color1 = incomingData.substring(0,3).toInt();
         int color2 = incomingData.substring(4,7).toInt();
         int color3 = incomingData.substring(8).toInt();
         setColor(color1, color2, color3);
    }
}