bicolor led color problem

Hey, i have a bi color led i'm trying to change the colors of the led with this code, but unfortunately its only change the intensity of the led, i'm new to that so... please help ? Thanks

int led = 8;
int led2 = 10;
long randNumber;
long randNumber2;

void setup()
{
Serial.begin(9600);

pinMode(led, OUTPUT); // set each pin as an output
pinMode(led2, OUTPUT); // set each pin as an output

}

void loop()
{

randNumber = random(300);
randNumber2 = random(300);

analogWrite(led, randNumber);
delay(100);
Serial.println(randNumber);
analogWrite(led2, randNumber2);
Serial.println(randNumber2);
delay(10);

}

Do you have a bi-colour LED where there are only two pins, or are there three (i.e. one is a common anode/cathode to the other two)?

What is the delay(100) for? Seems kind of out of place in the sequence of events.

You cannot change the intensity of the LED connected to pin 8 because it does not support PWM. Only pins 3, 5, 6, 9, 10 and 11 support PWM.

Found the problem thanks guys :wink:

And also:

AnalogWrite() only supports values up to 256

AnalogWrite() only supports values up to 256

255 actually :wink:

Arrrgh :slight_smile:

255 of course