We will start off by defining which pins on the Arduino are connected to the RGB pins on the LED:
#define REDPIN 11 #define BLUEPIN 10 #define GREENPIN 9
This code shows that the red pin is connected to the Arduino 11 PWM pin, the blue pin is connected to the Arduino 10 PWM pin and the green pin is connected to the Arduino 9 PWM pin. We are going to define an empty macro that will let the application code know whether we have a common anode or a common cathode RGB LED. The following code will do that:
If you are using a common cathode RGB LED, then comment or remove this line from your code. We will see how to use this when we look at the function that sets the colors of the LED. Now let's look at the setup() ...