void command

So I have written this code to cycle one RGB through three colors. Being a total noob, I cobbled the code together from several sources from Google searches and YT vids. I understand most of what is going on with the exception of this line -

void RGB_color(int red_light_value, int green_light_value, int blue_light_value)

I have several colors // out as when I left them in the RGB cycles through them all. However, this confuses me as I thought I defined the pins and name of the pins and called them with the Analog Write commands. I left the other colors in there as I have use for them later and thought they would not be displayed.

So I have three questions what does this command do:

void RGB_color(int red_light_value, int green_light_value, int blue_light_value)

Why does the RGB cycle through the other colors when on R G B are called with the Analog Write

And why is nothing required in void set up.

int red_light_pin= 10;
int green_light_pin = 11;
int blue_light_pin = 12;

void setup() {

}

void loop()
{

RGB_color(255, 0, 0); // Red
delay(1000);
RGB_color(0, 255, 0); // Green
delay(1000);
RGB_color(0, 0, 255); // Blue
delay(1000);
//RGB_color(255, 255, 125); // Raspberry
//delay(1000);
//RGB_color(0, 255, 255); // Cyan
//delay(1000);
//RGB_color(255, 0, 255); // Magenta
//delay(1000);
//RGB_color(255, 255, 0); // Yellow
//delay(1000);
//RGB_color(255, 255, 255); // White
//delay(1000);

}

{

analogWrite(red_light_pin, red_light_value);
analogWrite(green_light_pin, green_light_value);
analogWrite(blue_light_pin, blue_light_value);

delay (1500);

}

Hello Roger,

Welcome to the Arduino fora.
Before you do anything else please take a moment to read General guidance
And How to use this forum
Especially item #7 on posting code.

The code you have posted is incomplete and does not compile. After reading the above instructions please edit your post to include the full code in code tags </> as per the forum instructions.

Those things you are calling ‘void commands’ are called functions.

Thanks.

With exceptions not relevant here, all C / C++ code must be in a function (but NOT a function inside a function).
This

{

analogWrite(red_light_pin, red_light_value);
analogWrite(green_light_pin, green_light_value);
analogWrite(blue_light_pin, blue_light_value);

delay (1500);

}

is C / C++ code not in a function. Big trouble there. Possibly needs to be moved to inside the loop() function.

holdingpattern:
As to this "Why does the RGB cycle through the other colors when on R G B are called with the Analog Write" I don't understand the question.

I believe he means:
Why does the RGB cycle through the other colors when the function is only called for RED, GREEN, and BLUE?

holdingpattern:
Let's say he does. What does that mean :wink:

It means he is only expecting the colors red, green and blue but also gets other colors.