// Full Color LED random color generator // written by EgoPlast byte RedLED = 2; byte BluLED = 3; byte GrnLED = 4; int RedFade; int BluFade; int GrnFade; void setup () { pinMode (RedLED, OUTPUT); pinMode (BluLED, OUTPUT); pinMode (GrnLED, OUTPUT); Serial.begin (9600); } /* Random Color Generator */ void loop () { //get random color values (max at 255) RedFade = random(255); BluFade = random(255); GrnFade = random(255); //Now mix the colors analogWrite(RedLED,RedFade); analogWrite(BluLED,BluFade); analogWrite(GrnLED,GrnFade); //let me see the color mixture Serial.print ("current values "); Serial.print (RedFade); Serial.print (" : "); Serial.print (BluFade); Serial.print (" : "); Serial.println (GrnFade); /*This delay is mainly so you can read the values in the serial monitor. */ delay (1000); /* The Full color 5mm LED from RadioShack (276-0028) has 4 leads: (from the flat side of the LED body) pin 1 Red (-) pin 2 Positive Voltage pin 3 Blue (-) pin 4 Green (-) To trigger the desired color you set the pin to ground. so- if you want red, you would have voltage on pin 2 and pin 1 to ground. Here is the way this works a higher PWN number on analogWrite the LED will see a higher voltage on the pin. - if all three are set to 255 none of the lights will light because the LED will see HIGH on all pins and no Ground path Numbers closer to zero will cause the color to be more evident. as it approaches gnd */ }