Help with code

So i have 3 RGB leds connected on 3 of their legs to the 5V output from the arduino.
I want to shutdown all the leds at the same time with one code because in total i have 9 (3x3) legs to shutdown. I dont now how to use the array or the best function here.
Sorry if i have bad english.

Thanks

sketch_may29a.ino (2.94 KB)

I dont now how to use the array or the best function here.

for(byte i=0; i<(sizeof(apagadoledsunoatres) / sizeof(apagadoledsunoatres[0]); i++)
{
   digitalWrite(apagadoledsunoatres[i], LOW);
}

// Sorry my Italian (?) is not very good, so I hope I am reading your code correctly.
// Try the following instead of your setup function.

int initialState = { LOW, HIGH, HIGH, LOW, HIGH, HIGH, LOW, HIGH, HIGH};

setup()
{
for (int led = 0; led < 9; ++led)
{
pinMode(apagadoledsunoatres[led], OUTPUT);
digitalWrite(apagadoledsunoatres[led], initialState[led]);
}
pinMode(ledloop,OUTPUT);
}

// I don’t think you can set them up to all turn off at the same time without using transistors,
// but you can turn them off in code using a for loop, i.e.
for (int led = 0; led < 9; ++led)
{
digitalWrite(apagadoledsunoatres[led], LOW);
}

// Does that help?

xbuilder, ttam: Welcome to the Forum. It would help if you read the two posts at the top of this Forum by Nick Gammon for guidelines, When posting source code to the Forum, please use the code tags ("</>") after reformatting your code in the IDE with Ctrl-T. It will help us help you.