My Arduino Duemilanove arrived in the mail today.
So I ripped it open and after the blink tutorial I made this pretty crap thing.
Makes an RGB LED display a rainbow.
This is my very first arduino build should probably read some instructions or a tutorial xD
To figure out the colour values i used this colour mixer http://colormixers.com/mixers/cmr/
Any Suggestions on improvements would be appreciated
Video:
Code:
/*
*RAINBOW
*by CaptainCool
*
*Blinks an RGB LED through the ROYGBV colour selection
*
*
*/
int ledgreen = 11;
int ledblue = 12;
int ledred = 13;
void setup() {
pinMode(ledred, OUTPUT);
pinMode(ledblue, OUTPUT);
pinMode(ledgreen, OUTPUT);
}
void loop()
{
//red on
analogWrite(ledred, 255);
delay(1000);
//red off
analogWrite(ledred, 0);
delay(0);
//orange on
analogWrite(ledred, 255);
delay(0);
analogWrite(ledgreen, 128);
delay(1000);
//orange off
analogWrite(ledred, 0);
delay(0);
analogWrite(ledgreen, 0);
delay(0);
//yellow on
analogWrite(ledred, 255);
delay(0);
analogWrite(ledgreen, 215);
delay(1000);
//yellow off
analogWrite(ledred, 0);
delay(0);
analogWrite(ledgreen, 0);
delay(0);
//green on
analogWrite(ledgreen, 255);
delay(1000);
//green off
analogWrite(ledgreen, 0);
delay(0);
//blue on
analogWrite(ledblue, 255);
delay(1000);
//blue off
analogWrite(ledblue, 0);
delay(0);
//purple on
analogWrite(ledred, 255);
delay(0);
analogWrite(ledblue, 255);
delay(1000);
//purple off
analogWrite(ledred, 0);
delay(0);
analogWrite(ledblue, 0);
delay(0);
}
I'm surprised your LEDs didn't burn out by now, without resistors and whatnot. If you're just starting out I can't blame you--everyone's blown up a few electronic components before. But you should always include current limiting resistors with an LED so that you don't fry either your arduino or your LED