Wednesday, December 5, 2012

RGB LED using 3 leds. And random numbers




/* random numbers on 3 leds to create a cool effect
Also controlling 3 red, green and blue leds to create a bigger RGB led.
*/

int blue = 3;
int red = 5;
int green = 6;
int randred;
int randblue;
int randgreen;

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

  pinMode(blue, OUTPUT);
  pinMode(red,OUTPUT);
  pinMode(green,OUTPUT);
  randomSeed(analogRead(0));
}
void loop(){
  randblue = random(0,256);
  randred = random(0,256);
  randgreen = random(0,256);

  analogWrite(blue,randblue);
  analogWrite(red,randred);
  analogWrite(green,randgreen);

   Serial.println(randred);
   Serial.println(randblue);
   Serial.println(randgreen);

  delay(100);

}


No comments:

Post a Comment