Does McWhorther publish his solutions?
I'd like to see what he expects you to be able to do at this point, I'm betting it is done in a very simple manner.
Later.
McWhorther seems to use neither switch/case, the ternary operator nor functions at this point.
He does not publish, or TBC I could not find solutions to homework problems. But looking ahead to the ultimate sketch he expects you will arrive at, we see indeed he continues in his straight code all in the loop style. Appropriate for where he's led you.
He uses a global variable
float dFact = 1; // dimming factor
And using the way he links any IR button to an action, handles dimming (and undimming) by tweaking and constraining the brightness factor, viz:
if (myCom == "dn") {
dFact = dFact * 0.75; // dim
}
if (myCom == "up") {
dFact = dFact * 1.30; // brighten
if (dFact > 1) {
dFact = 1; //... fix overflow
}
}
I expect you could fit that into your switch statement.
Later, at the point of writing the values, the brightness factor is applied:
analogWrite(rPin, rBright * dFact);
analogWrite(gPin, gBright * dFact);
analogWrite(bPin, bBright * dFact);
I guess he isn't terribly worried about the physiology of human vision WRT PWM modulated RGB LEDs.
Everyone learns differently: I think it is useful to see things done literally as is McW's habit, and perhaps suffer a bit while writing code that way.
At the very least it makes the actual necessary steps of the algorithm the issue, rather than any fancy languages features you dress them up in.
a7

