Code For Lighting RGB Led
why were they able to carry out setColor before expanding upon what it means later

You are correct in C that is the case. However the Arduino IDE adds &quot;function prototypes&quot; to the top of your code automatically. That means you no longer have to abide by the &quot;define before use&quot; of C and C++.

I know what 255 would indicate maximum brightness, but why do you have to subtract the color from 255?

This is for if your LED is &quot;common anode&quot; instead of &quot;common cathode&quot;. With a common anode LED you write a LOW to turn it on and a HIGH to turn it off - this is the exact opposite of a common cathode.
So to set the brightness of a common anode LED you need to use the opposite value, and since PWM goes from 0-255 the opposite is 255-0: 255 is off, and 0 is fully on.