OK, you need to use a variable to indicate which color was selected with the button press.
void loop()
{
static byte selectedColor = 0; // 0 == R, 1 == G, 2 == B
}
And every time the button is pressed, you can increment the variable.
void loop()
{
static byte selectedColor = 0; // 0 == R, 1 == G, 2 == B
if(buttonState == HIGH)
{
selectedColor++;
if(selectedColor >= 3)
{
selectedColor = 0;
}
}
}
Now you can take decisions based on the value of selectedColor; it can be done with if / else if / else or with switch/case
[code]
void loop()
{
static byte selectedColor = 0; // 0 == R, 1 == G, 2 == B
if(buttonState == HIGH)
{
selectedColor++;
if(selectedColor >= 3)
{
selectedColor = 0;
}
}
switch(selectedColor)
{
case 0:
// set red color
...
...
break;
case 1:
// set green color
...
...
break;
case 2:
// set blue color
...
...
break;
}
}
Now you will encounter a couple of problems.
The first one will be bounce; one press might result in multiple transitions from LOW to HIGH (and vice versa). The IDE comes with a debounce example; understand it and adjust to your needs.
Once you have taken that hurdle, you will find out that it still does not work because loop() is executed thousands of time in a second. So you basically need to react on a change from LOW to HIGH and not on the HIGH state. The IDE comes with a statechange example; again understand it and adjust to your needs.