Monday, October 5, 2009

Revisited

A few changes to the Lotus lamp

6 LED's instead of 3
parchment paper construction (desig y-er, no?))

The code can of course be found below the video-

/*
RGB Transitions

This Program cycles through an RGB array of LED's to reproduce a full
spectrum of color gradiants.
Created 10 September 2009
By Eric Harman

Based on "Fading" by:
Created 1 Nov 2008
By David A. Mellis
Modified 17 June 2009
By Tom Igoe
http://arduino.cc/en/Tutorial/Fading
*/


int redPin = 11; // LED connected to digital pin 11
int greenPin = 10; // LED connected to digital pin 10
int bluePin = 9; // LED connected to digital pin 9
int fadeValue = 0; //Declare Variable and set intitial value


void setup() {

}

void loop() {
if ( fadeValue = 0) {
// do stuff if the condition is true
// fade in Red LED:
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
// sets the value (range from 0 to 255):
analogWrite(redPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(100);
}
// fade in green LED:
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
// sets the value (range from 0 to 255):
analogWrite(greenPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(100);
}
} else {
// do stuff if the condition is false
// fade in green LED:
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
// sets the value (range from 0 to 255):
analogWrite(greenPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(100);
}
}
// fade out Red LED:
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
// sets the value (range from 0 to 255):
analogWrite(redPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(100);
}
// fade in Blue LED:
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
// sets the value (range from 0 to 255):
analogWrite(bluePin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(100);
}
// fade out Green LED:
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
// sets the value (range from 0 to 255):
analogWrite(greenPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(100);
}
// fade in Red LED:
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
// sets the value (range from 0 to 255):
analogWrite(redPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(100);
}
// fade out Blue LED:
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
// sets the value (range from 0 to 255):
analogWrite(bluePin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(100);
}
}

No comments:

Post a Comment