Z Looking Glass: Project SmartSurfaces

A insider's observation of Project SmartSurface

Arduino, LED, C++, and “Big Wave” September 19, 2009

Filed under: Uncategorized — zilinzen @ 3:58 am

Alternate & Mix Red, Green and Blue with Fading Feature

By mixing RGB, my lamp can alternate colors from Alternating Red, Blue, Green, Violet, Turquoise, and Yellow. This is implemented by using while loop, if…else and analogWrite features to control the amount of voltage in a specific pin that connects to a LED. By adding some conditions, the alternating and mixing processes were optimized to smooth transitions between colors.


Breadboard Design

Three LEDs are connected in parallel, each with a 1K-ohm resistor. One interesting thing I noticed is that when connecting two LEDs with one 1K resistor in series, the lamps won’t turn on. Maybe it’s because the voltage allocated to each LED is below the energy threshold. That’s the reason to connect them in parallel, so we can make sure each one will turn on.

_MG_1168

RGB LEDs are connected in parallel, each connected in serie with a 1K-ohm resistor

Lampshade Design

The lampshade is called “Big Wave”, inspired by the famous Japanese canvas painting: “The Great Wave off Kanagawa” (1831) by Katsushika Hokusai and a very innovative punctured paper lampshade designed and made in Brooklyn by warpeDesign. Some of the dotted patterns are also influenced by the unique design from Italian fashion house: Missoni.(http://www.missoni.com)

the_great_wave_off_kanagawa

"The Great Wave off Kanagawa" created by Katsushika Hokusai in 1820s

Two foam cups stacking together are the main structure of the lamp. A piece of Kleenex in between them is used to diffuse the RGB lights emitted from LEDs in order to better mix the colors.

il_430xN.75965126

Punctured paper lampshade designed and made in Brooklyn by warpeDesign

Arduino Code:
/*
 Alternate & Mix Red, Green and Blue with Fading Feature
 */
int redPin =  9;    // Red LED connected to digital pin 9
 int greenPin = 11;   // Green LED to pin 11
 int bluePin = 10;   // Blue LED to pin 10
// The setup() method runs once, when the sketch starts
void setup()   {
 // initialize the digital pin as an output:
 pinMode(redPin, OUTPUT);
 pinMode(greenPin, OUTPUT);
 pinMode(bluePin, OUTPUT);
 }
// the loop() method runs over and over again,
 // as long as the Arduino has power
void loop()    {
 //Fading code
 int pinVal = 9;    //At first run, it starts at pin 9 (red LED)
//Single Lighting
 while(pinVal <= 11) {
 for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=1) {
 // sets the value (range from 0 to 255):
 analogWrite(pinVal, fadeValue);
 // wait for 30 milliseconds to see the dimming effect
 delay(20);
 }
// fade out from max to min in increments of 1 point:
 for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=1) {
 // sets the value (range from 0 to 255):
 analogWrite(pinVal, fadeValue);
 // wait for 30 milliseconds to see the dimming effect
 delay(20);
 }
pinVal++;
 } //end of Single Lighting
 pinVal = 9;
//Pair Lighting
 while(pinVal <= 11) {
if (pinVal < 11) {
 for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=1) {
 // sets the value (range from 0 to 255):
 analogWrite(pinVal, fadeValue);
 analogWrite(pinVal + 1, fadeValue);
 // wait for 30 milliseconds to see the dimming effect
 delay(20);
 }
// fade out from max to min in increments of 1 point:
 for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=1) {
 // sets the value (range from 0 to 255):
 analogWrite(pinVal, fadeValue);
 analogWrite(pinVal + 1, fadeValue);
 // wait for 30 milliseconds to see the dimming effect
 delay(20);
 }
 } //end of if
else if (pinVal = 11) {
 // fade out from max to min in increments of 1 point:
 for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=1) {
 // sets the value (range from 0 to 255):
 analogWrite(pinVal, fadeValue);
 analogWrite(pinVal - 2, fadeValue);
 // wait for 30 milliseconds to see the dimming effect
 delay(20);
 }
// fade out from max to min in increments of 1 point:
 for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=1) {
 // sets the value (range from 0 to 255):
 analogWrite(pinVal, fadeValue);
 analogWrite(pinVal -2, fadeValue);
 // wait for 30 milliseconds to see the dimming effect
 delay(20);
 }
 } //end of else if
pinVal++; //increment of pinVal for while loop
 } //End of Pair Lighting
 }