Ok, I did that, and then I did this code to test it:
const byte PIN_RED = 9;
const byte PIN_GREEN = 10;
const byte PIN_BLUE = 11;
void color(unsigned long v)
{
byte red = v & 255;
byte green = (v >> 8) & 255;
byte blue = (v >> 16) & 255;
analogWrite(PIN_RED, red);
analogWrite(PIN_GREEN, green);
analogWrite(PIN_BLUE, blue);
// red green blue values are available for other uses
}
void setup()
{
Serial.begin(9600);
pinMode(PIN_RED, OUTPUT);
pinMode(PIN_GREEN, OUTPUT);
pinMode(PIN_BLUE, OUTPUT);
randomSeed(analogRead(0));
color((unsigned long)random(0x01000000));
}
void loop()
{
if(PIN_RED > 100);{
Serial.print("redled on ");
}
if(PIN_RED < 100);{
Serial.print("redled off ");
}
delay(3000);
}
Unfortunately, the serial monitor just says "led on led off" every 3 seconds. Why does it do that?