Show Posts
Pages: [1]
1  Community / Exhibition / Gallery / Re: My First Sketch: PWM Common Annode RGB Led 7 Color Generator on: January 17, 2013, 12:21:16 am
WHOOPS! I should have known better! For shame on me...

I'll correct it as soon as I can. Thanks for the heads up!

 smiley-lol

EDIT: I updated the image and it should be visible above. Feel free to use it.
2  Community / Exhibition / Gallery / My First Sketch: PWM Common Annode RGB Led 7 Color Generator on: January 16, 2013, 12:09:06 am
I picked up my first Arduino and I am impressed with it's capabilities. Just thought I'd share my first sketch. It uses the common annode, full color LED, Radio Shack model # 276-028. I used three PWM outputs to fade out each of the 7 basic color combination that can be made with the RGB LED. I am sure this code could be done simpler but I had so much fun getting it to work so easily! I can't wait to think up more things to make!

Code:
// RGB 7 Color Fade Out Looper
// By: CLM3S

// Define LED Color Pin Outputs
int RedPin = 11;
int GreenPin = 10;
int BluePin = 9;

void setup()
{
}
 
void loop()
{

  // Fade Out Red
  for (int x=0; x<256; x=x+5) {
    analogWrite (RedPin, x);  
    delay(10);  
  }
  // Clear All Colors
  analogWrite (RedPin, 255);  
  analogWrite (GreenPin, 255);  
  analogWrite (BluePin, 255);    
  delay(25);

  // Fade Out Green
  for (int x=0; x<256; x=x+5) {
    analogWrite (GreenPin, x);  
    delay(10);  
  }
  // Clear All Colors
  analogWrite (RedPin, 255);  
  analogWrite (GreenPin, 255);  
  analogWrite (BluePin, 255);    
  delay(25);

  // Fade Out Blue
  for (int x=0; x<256; x=x+5) {
    analogWrite (BluePin, x);    
    delay(10);  
  }
  // Clear All Colors
  analogWrite (RedPin, 255);  
  analogWrite (GreenPin, 255);  
  analogWrite (BluePin, 255);    
  delay(25);

  // Fade Out Cyan
  for (int x=0; x<256; x=x+5) {
    analogWrite (GreenPin, x);  
    analogWrite (BluePin, x);    
    delay(10);  
  }
  // Clear All Colors
  analogWrite (RedPin, 255);  
  analogWrite (GreenPin, 255);  
  analogWrite (BluePin, 255);    
  delay(25);

  // Fade Out Yellow
  for (int x=0; x<256; x=x+5) {
    analogWrite (RedPin, x);  
    analogWrite (GreenPin, x);  
    delay(10);  
  }
  // Clear All Colors
  analogWrite (RedPin, 255);  
  analogWrite (GreenPin, 255);  
  analogWrite (BluePin, 255);    
  delay(25);
  
  // Fade Out Magenta
  for (int x=0; x<256; x=x+5) {
    analogWrite (RedPin, x);  
    analogWrite (BluePin, x);    
    delay(10);  
  }
  // Clear All Colors
  analogWrite (RedPin, 255);  
  analogWrite (GreenPin, 255);  
  analogWrite (BluePin, 255);    
  delay(25);

  // Fade Out White
  for (int x=0; x<256; x=x+5) {
    analogWrite (RedPin, (x / 2) + (256 - (256 / 2)));  
    analogWrite (GreenPin, x);  
    analogWrite (BluePin, x);    
    delay(10);  
  }
  // Clear All Colors
  analogWrite (RedPin, 255);  
  analogWrite (GreenPin, 255);  
  analogWrite (BluePin, 255);    
  delay(25);

}



Enjoy!  smiley
Pages: [1]