# Electrical – Arduino rgb loop

arduino

So I have an rgb led and I can change the color with:

    setColor(r, g, b);


I want a loop to loop through all the possible combinations how can I do this?

This can be easily achieved with nested for loops:

int R;
int G;
int B;

void loop()
{
for (R = 0 ; R < 256 ; R++)
{
for (G = 0 ; G < 256 ; G++)
{
for (B = 0 ; B < 256 ; B++)
{
setColor(R,G,B);
}
}
};
}


It would be really nice if you put some more effort into your work... Hope it helps. Best of Luck!!