Random RGB

Well, I thought I posted this a long time ago, but I can’t find any evidence… I guess I’ll just post it…

This is my “Random RGB” project… It selects 1 of 9 colors, and then coems up with a random time to display that color. You use the “Color Finder” to find out the falues you want your colors to be. Then you put those values in the actual “Random RGB”, and you’re set!

As always, I love feedback (good or bad), as long as it is helpful, and not just mean.

Color Finder

// This is the RGB value finder. Use this to find the red, green, and blue values of your colors.
// Written by Jeremy Carlson.
// Known as Jeremy1998 on the Arduino Forums.

int redPot = 0;
int greenPot = 1;      
int bluePot = 2;

int redLed = 11;       
int greenLed = 10;
int blueLed = 9;

int redVal;
int greenVal;
int blueVal;

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

 pinMode(redLed, OUTPUT);  
 pinMode(greenLed, OUTPUT);  
 pinMode(blueLed, OUTPUT);   
}

void loop()
{
 redVal = analogRead(redPot);
 redVal = map(redVal, 0, 1023, 0, 255); 
 greenVal = analogRead(greenPot);
 greenVal = map(greenVal, 0, 1023, 0, 255); 
 blueVal = analogRead(bluePot);
 blueVal = map(blueVal, 0, 1023, 0, 255);  
 
 Serial.print("Red:"); 
 Serial.print(redVal);
 Serial.print(",");
 Serial.print("Green:"); 
 Serial.print(greenVal);
 Serial.print(",");
 Serial.print("Blue:"); 
 Serial.println(blueVal);
 
 analogWrite(redLed, redVal);
 analogWrite(greenLed, greenVal);
 analogWrite(blueLed, blueVal);  
 
 delay(25);
}

Random RGB

// This is the Random RGB Led coloring system. It chooses a random color to display on the RGB led. 
// Written by Jeremy Carlson.
// Known as Jeremy1998 on the Arduino Forums.

int redLed = 11;
int greenLed = 10;
int blueLed = 9;

long randNumb;
long randTime;

void setup()
{
 pinMode(redLed, OUTPUT);
 pinMode(greenLed, OUTPUT);
 pinMode(blueLed, OUTPUT); 
}

void red()
{
 analogWrite(redLed, 255);
 analogWrite(greenLed, 0); 
 analogWrite(blueLed, 0);  
}  

void green()
{
 analogWrite(redLed, 0);
 analogWrite(greenLed, 255); 
 analogWrite(blueLed, 0);  
}  

void blue()
{
 analogWrite(redLed, 0);
 analogWrite(greenLed, 0); 
 analogWrite(blueLed, 255);  
}  

void yellow()
{
 analogWrite(redLed, 255);
 analogWrite(greenLed, 255); 
 analogWrite(blueLed, 0);  
}  

void orange()
{
 analogWrite(redLed, 255);
 analogWrite(greenLed, 35); 
 analogWrite(blueLed, 255);  
}  

void pink()
{
 analogWrite(redLed, 255);
 analogWrite(greenLed, 0); 
 analogWrite(blueLed, 162);  
}  

void purple()
{
 analogWrite(redLed, 88);
 analogWrite(greenLed, 0); 
 analogWrite(blueLed, 112);  
}  

void bluegreen()
{
 analogWrite(redLed, 0);
 analogWrite(greenLed, 144); 
 analogWrite(blueLed, 255);  
}  

void white()
{
 analogWrite(redLed, 255);
 analogWrite(greenLed, 255); 
 analogWrite(blueLed, 255);  
}  

void loop() 
{
 randNumb = random(1, 10);      // Generate a random number between 1 and 10
 randTime = random(250, 1001);  // Generate a random number between 250 and 1000
 
 if(randNumb == 1){
  red(); 
 }  
 if(randNumb == 2){
  green();
 }
 if(randNumb == 3){
  blue();
 }
 if(randNumb == 4){
  yellow();
 }
 if(randNumb == 5){
  orange();
 }
 if(randNumb == 6){
  pink();
 }
 if(randNumb == 7){
  purple();
 }
 if(randNumb == 8){
  bluegreen();
 }
 if(randNumb == 9){
  white();
 }
       
 delay(randTime);
}

Love all of the feedback so far! (SARCASM!!!)

Nobody likes it???

I didn't receaved my Arduino from the mail yet. I'm going to give you feedback maybe this wednesday. ;)

Care to explain how does this work, in details? :D (it display the color on the pc?)

It displays on an RGB led conneted to pins 11, 10, and 9.

SENIOR MEMBER!!!!!

man, I should have read the void setup ;D The first code give you the 3 RGB values that is displayed by your RGB led and who was set by 3 variables resistors?

Yeah... I think...

The firat part has an RGB Led, 3 Pots, and the serial monitor. You turn the pots to adjust the brightness of the led. It displays these values in the serial monitor.

Wow!!! 1 freaking person gives a s**t about my project... Feels great...

nicely done

Great i may use this to light up a project I'm working on this looks like just the right thing to get me started.

Some time back I did this with an added smoothness - every time a new color was generated, instead of jumping right to that color, a for loop incremented the rgb values until it got there - put a little paper box over it, and it made a pretty cool mood-light. You should try appending that to your code.

Shouldn't be too hard... A couple of if statements and +5 or -5... Ill give it a try...