I'm having a really hard time getting this RGB Led working with my arduino. First i'll describe my setup (schematic) , and then i'll show you the code I have.
I have 5 volts going into the second pin of the RGB LED , then I have 3 200 ohm resistors on each of the pins going out of the LED which respectively lead into PMW 9,10,11 of my arduino.
(The led setup) pin 1 Red (-) pin 2 Positive Voltage pin 3 Blue (-) pin 4 Green (-)
The code I have is
byte Red = 9;
byte Blu = 10;
byte Grn = 11;
void setup ()
{
pinMode (Red, OUTPUT);
pinMode (Blu, OUTPUT);
pinMode (Grn, OUTPUT);
}
int x=255;
int y=0;
int z=0;
void loop ()
{
analogWrite(Red,x);
analogWrite(Blu,y);
analogWrite(Grn,z);
}
The above code is supposed to produce a red light, but it produces a purple. I feel like it is something really simple.... Thanks