Go Down

Topic: Random RGB (Read 1 time) previous topic - next topic

Jeremy1998

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
Code: [Select]
// 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
Code: [Select]
// 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);
}

Jeremy1998

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

Jeremy1998

Nobody likes it???

sxdemon

#3
Oct 03, 2010, 07:25 pm Last Edit: Oct 03, 2010, 07:29 pm by kraig Reason: 1
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?)

Jeremy1998

#4
Oct 04, 2010, 12:30 am Last Edit: Oct 04, 2010, 12:32 am by Jeremy1998 Reason: 1
It displays on an RGB led conneted to pins 11, 10, and 9.

SENIOR MEMBER!!!!!

sxdemon

#5
Oct 04, 2010, 12:36 am Last Edit: Oct 04, 2010, 12:40 am by kraig Reason: 1
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?

Jeremy1998

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.

Jeremy1998

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

weirdo557


The_burrito_master

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.

jezuz

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.

Jeremy1998

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

Go Up