As computing becomes more ubiquitous in our objects, designers need to be more aware of how to design meaningful interactions into electronically enhanced objects. At the University of Washington, a class of junior Interaction Design majors is exploring this question. These pages chronicle their efforts.

Wednesday, June 11, 2014

Stellio (Color-Selecting Lamp) (Charlotte and Kendall)

Charlotte and Kendall's Color-Selecting Lamp We created a lamp that changes color based on the color of an object that the user holds up to it. It utilizes an RGB sensor to detect the color and displays this color in the RBG LED strip. We purchased an ikea ceiling lamp and modified it to fit our purposes. We laser-cut a sheet of acrylic (which we then sanded and spray-painted white) to create an inner-housing for the arduino, breadboard and LEDs. The code for our lamp is as follows: #include #include "Adafruit_TCS34725.h" // Pick analog outputs, for the UNO these three work well // use ~560 ohm resistor between Red & Blue, ~1K for green (its brighter) #define redpin 3 #define greenpin 6 #define bluepin 9 // for a common anode LED, connect the common pin to +5V // for common cathode, connect the common to ground // set to false if using a common cathode LED #define commonAnode false // our RGB -> eye-recognized gamma color byte gammatable[256]; Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_50MS, TCS34725_GAIN_16X); void setup() { Serial.begin(9600); Serial.println("Color View Test!"); if (tcs.begin()) { Serial.println("Found sensor"); } else { Serial.println("No TCS34725 found ... check your connections"); while (1); // halt! } // use these three pins to drive an LED pinMode(redpin, OUTPUT); pinMode(greenpin, OUTPUT); pinMode(bluepin, OUTPUT); // thanks PhilB for this gamma table! // it helps convert RGB colors to what humans see for (int i=0; i<256; i++) { float x = i; x /= 255; x = pow(x, 2.5); x *= 255; if (commonAnode) { gammatable[i] = 255 - x; } else { gammatable[i] = x; } //Serial.println(gammatable[i]); } } void loop() { //this is the sensor read code uint16_t clear, red, green, blue; tcs.setInterrupt(false); // turn on LED delay(60); // takes 50ms to read tcs.getRawData(&red, &green, &blue, &clear); tcs.setInterrupt(true); // turn off LED if (clear >= 10000){ Serial.print("C:\t"); Serial.print(clear); Serial.print("\tR:\t"); Serial.print(red); Serial.print("\tG:\t"); Serial.print(green); Serial.print("\tB:\t"); Serial.print(blue); // Figure out some basic hex code for visualization uint32_t sum = clear; float r, g, b; r = red; r /= sum; g = green; g /= sum; b = blue; b /= sum; r *= 256; g *= 256; b *= 256; Serial.print("\t"); Serial.print((int)r, HEX); Serial.print((int)g, HEX); Serial.print((int)b, HEX); Serial.println(); //Serial.print((int)r ); Serial.print(" "); Serial.print((int)g);Serial.print(" "); Serial.println((int)b ); analogWrite(redpin, gammatable[(int)r]); analogWrite(greenpin, gammatable[(int)g]); analogWrite(bluepin, gammatable[(int)b]); } // close of if }

No comments:

Post a Comment