I suggest you add another variable byte selectedColour =0; which can take any of the values 0, 1, 2 for Red Green or Blue.
Also make 3 variables to hold the value for each colour byte blueVal = 0; etc.
Then read check when your button changes from OFF to ON with something like
buttonVal = digitalRead(buttonPin);
if (buttonVal == LOW && prevButtonVal == HIGH) {
selectedColour += 1; // move to next colour
if (selectedColour > 2) {
selectedColour = 0;
}
}
prevButtonVal = buttonVal;
(That could all go in a buttonRead() function)
Then, elsewhere in your program you have something like
if (selectedColour == 0) {
redVal = analogVal / 4;
}
else if (selectedColor == 1) {
blueVal = analogVal / 4;
}
else {
greenVal = analogVal / 4;
}
And if you were to use an array to hold the colour values it could be even shorter
colourVal[selectedColour] = analogVal / 4;
The trick is to separate the reading of the button from the setting of the colours by using a variable as an intermediary. The variable will remember its setting until the next time it is changed.
...R