The inspiration for my LED chair/cushion came from giving mundane inanimate objects such as furniture another layer of interaction with the user. The choice to use temperature as a control value also helps to personify the item
The inspiration for my LED chair/cushion came from giving mundane inanimate objects such as furniture another layer of interaction with the user. The choice to use temperature as a control value also helps to personify the item
The final version showing the temperature sensor starting, warming up then cooling down
/********************************************************************
Author : Steven Reid
Last Modified : 20th March,2012 Created : 20th February,2012
File : LED_Case.ino
Target Hardware: Arduino Duemilanove /w ATmega328
Version : 1.0
Description : ws2801 LED strip controlled by a TMP36 analog temperature sensor
Includes : http://www.sparkfun.com/datasheets/Components/LED/LED_Strip_Example.pde (LED Strip)
http://www.ladyada.net/learn/sensors/tmp36.html (Temperature sensor)
*********************************************************************************/
int SDI = 2; //Data Wire (Red)
int CKI = 3; //Clock Wire (Green)
int tempPin = 0; //the analog pin the TMP36’s Vout (sense) pin is connected to
//the resolution is 10 mV / degree centigrade with a
//500 mV offset to allow for negative temperatures
int ambient = 0; //Variable that holds the ambient room temperature
int switchTemp = 0; //Temperature variable that controlls the switch case
long ledColor = 0; //Variable that holds the hexadecimal colour value
float temperatureC = 0; //Variable that holds the temperature in degrees centigrade
#define STRIP_LENGTH 64 //Array Lenght(32 LEDs on each strip)
long strip_colors[STRIP_LENGTH]; //Array of LED colour values
//Functions to be carried out on device startup
void setup() {
pinMode(SDI, OUTPUT); //Setting data pin as an output
pinMode(CKI, OUTPUT); //Setting clock pin as an output
pinMode(tempPin, INPUT); //Setting temperature pin as an input
for(int x = 0 ; x < STRIP_LENGTH ; x++) // Clearing the array by filling it with blank values
strip_colors[x] = 0;
getTemp(); // Calling the get temperature function
ambient = temperatureC; //Collecting the ambient temperature value when the device is started
}
//Main program loop
void loop() {
while(1){ //Do forever
getTemp(); // Calling the get temperature function
temp_colour(); // Calling the get colour function
fillArray(); // Calling the fill array function
post_frame(); // Calling the display LED function
}
}
//Reads in the temperature value and converts into degrees c
void getTemp(void) {
//getting the voltage reading from the temperature sensor
int reading = analogRead(tempPin);
// converting that reading to voltage
float voltage = reading * 5.0;
voltage /= 1024.0;
// now convert voltage to temperature(not essential but makes code more readable)
temperatureC = (voltage - 0.5) * 100 ; //converting from 10 mv per degree wit 500 mV offset
switchTemp = (temperatureC - ambient); // creating the value to control the case statement
}
//Using the temperature value to generate the LED colour
void temp_colour (void) {
switch (switchTemp){
//Case statement generating the LED colour
case 1: //if temperature difference is 1 the do….
ledColor = 0x0000FF;//blue(Hex colour value)
break; //Return to main loop
case 2:
ledColor = 0x3D59AB;//cobaltblue
break;
case 3:
ledColor = 0x6495ED;//cornflourblue
break;
case 4:
ledColor = 0xCAE1FF; //lightsteelblue
break;
case 5:
ledColor = 0xCDB5CD;//thistle3
break;
case 6:
ledColor = 0xFFBBFF;//plum1
break;
case 7:
ledColor = 0xEECFA1;//navajowhite2
break;
case 8:
ledColor = 0xEEE685; //khaki2
break;
case 9:
ledColor = 0xFFFF00;//yellow
break;
case 10:
ledColor = 0xEEC900;//gold
break;
case 11:
ledColor = 0xFF8000;//orange
break;
case 12:
ledColor = 0xEE7600;//darkorange
break;
case 13:
ledColor = 0xFF6103; //cadmiumorange
break;
case 14:
ledColor = 0xFF4500;//orangered
break;
case 15:
ledColor = 0xFF0000; //red
break;
//default position to prevent errors
default:
if (switchTemp <= 0){
ledColor = 0x0000FF; //blue
}
else if (switchTemp >= 15){
ledColor = 0xFF0000; //red
}
break;
}
}
//Adds the new led colour and trickles it down the strip
void fillArray(void) {
int x; //0 value for the for loop
//Shuffle all the current colors down one spot on the strip
for(x = (STRIP_LENGTH - 1) ; x > 0 ; x—)
strip_colors[x] = strip_colors[x - 1];
strip_colors[0] = ledColor; //Add the color to the first position on the strip
}
//Takes the current strip color array and pushes it out
void post_frame (void) {
//Each LED requires 24 bits of data
//Once the 24 bits have been delivered, the IC immediately relays these bits to its neighbor
//Pulling the clock low for 500us or more causes the IC to post the data.
//Assigns data to the led
for(int LED_number = 0 ; LED_number < STRIP_LENGTH ; LED_number++) {
long this_led_color = strip_colors[LED_number]; //24 bits of color data
for(byte color_bit = 23 ; color_bit != 255 ; color_bit—) {
//Feed color bit 23 first (red data MSB)
digitalWrite(CKI, LOW); //Only change data when clock is low
long mask = 1L « color_bit;
//The 1’L’ forces the 1 to start as a 32 bit number, otherwise it defaults to 16-bit.
if(this_led_color & mask)
digitalWrite(SDI, HIGH); //Puul data high
else
digitalWrite(SDI, LOW); //Pull data low
digitalWrite(CKI, HIGH); //Data is latched when clock goes high
}
}
digitalWrite(CKI, LOW); //Pull clock low to put strip into reset/post mode
delayMicroseconds(500); //Wait for 500us to go into reset
}
When the LED’s are changing colour the LED’s are flashing on and off too fast. I was hoping the colour change would be more gradual. To overcome this issue I will implement a function that trickles the new colour down the strip.


To refine the final product I removed the sensor and connections from the breadboard and soldered them to a protoshield. I have also wire the onboard pushbutton switch to port 13.

To ensure that the LED strip remained in place around the perimeter of the cushion I have sewn in loops every 10cm to create a channel for the strip to feed through.
To easily convey the idea of a piece of furniture with embedded LED’s if have decided to place the LED’s in a 50x50 cushion. The temperature sensor and Arduino will remain external for demonstration purposes.

The cushion will require two of the LED strips connected together and placed around the edge
To improve the initial version of the coursework I have used a case statement to replace the if/else if and increased the of amount colour increments to 15. Each increment is one degrees centigrade.