system
May 11, 2010, 12:24pm
#1
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:
http://www.youtube.com/watch?v=TaRwA1QKohY
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);
}
system
May 11, 2010, 2:19pm
#2
I changed all the code so it fades through the rainbow.
Video:
Here is my revised code:
/*
*FADING RAINBOW
*by CaptainCool
*
*Fades through a rainbow of colour.
*
*/
int ledRed = 9;
int ledGreen = 10;
int ledBlue = 11;
void setup()
{
//fade in red
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
analogWrite(ledRed, fadeValue);
delay(50);
}
}
void
loop() {
//fade in green
for(int fadeValue2 = 0 ; fadeValue2 <= 255; fadeValue2 +=5) {
analogWrite(ledGreen, fadeValue2);
delay(50);
}
//fade out red
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
analogWrite(ledRed, fadeValue);
delay(50);
}
//fade in blue
for(int fadeValue3 = 0 ; fadeValue3 <= 255; fadeValue3 +=5) {
analogWrite(ledBlue, fadeValue3);
delay(50);
}
//fade out green
for(int fadeValue2 = 255 ; fadeValue2 >= 0; fadeValue2 -=5) {
analogWrite(ledGreen, fadeValue2);
delay(50);
}
//fade in red
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
analogWrite(ledRed, fadeValue);
delay(50);
}
// fade out blue
for(int fadeValue3 = 255 ; fadeValue3 >= 0; fadeValue3 -=5) {
analogWrite(ledBlue, fadeValue3);
delay(50);
}
}
Any easier way i could’ve done this?
Where did you buy your arduino?
It doesn't look like theres any resistors on the RGB LED, which suggests the new Arduino won't last too long......
bld
May 11, 2010, 5:06pm
#6
Where did you buy your arduino?
You can get a list of places here: http://arduino.cc/en/Main/Buy
system
May 11, 2010, 8:05pm
#7
This is my very first arduino build should probably read some instructions or a tutorial
Resistors are your friend. My only suggestion is keep playing with it, they're so fun!
system
May 11, 2010, 9:29pm
#8
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
system
May 11, 2010, 10:09pm
#9
There is a 330ohm resistor on the LED it’s just near impossible to see in the second video. It wasn’t there in the first one. Didn’t think. xD
Where did you buy your arduino?
I got my arduino from nicegear (www.nicegear.co.nz) which is a New Zealand site because i’m from New Zealand