Making Furniture Interactive

December 17, 2007

[Dan D.W. Kang] Final Project- Interactive Coffee Table

Filed under: Dong Woo Kang,Final Project — dwkang @ 5:07 pm

dscn1305.jpgdscn1303.jpgdscn1300.jpgdscn1292.jpgdscn1287.jpgdscn1286.jpgdscn1285.jpgdscn1284.jpgdscn1280.jpgdscn1278.jpg

* Description

This interactive coffee table responds to the users and objects (coffee cups) by giving out different shades of light.

Two I/R sensors are attached on each side of the table to detect how many people there are. Two photocells are attached on the top of the table at both ends to detect how many coffee cups are being used. Depending on how many people or coffee cups there are, the table will respond differently with different shades and intensity of color. The table reaches its happiest state when the table is being fully utilized; two people sitting at the table, both of them drinking coffee. The table will entertain the users by flashing colorful lights and spinning.

* Code

int lightVal = 0;
int lightValB = 0;
int distanceVal = 0;
int distanceValB = 0;
int lightsensor = 0;
int lightsensorB = 2;
int distancesensor = 3;
int distancesensorB = 1;
int green = 11;
int red = 9;
int blue = 10;
int greenB = 3;
int redB = 5;
int motor = 7;
int value = 0;
int state = 1;
void setup() {
  pinMode(lightsensor, INPUT);
  pinMode(lightsensorB, INPUT);
  pinMode(distancesensor, INPUT);
  pinMode(distancesensorB, INPUT);
  pinMode(motor,OUTPUT);
  pinMode(red,OUTPUT);
  pinMode(green,OUTPUT);
  pinMode(blue,OUTPUT);
  pinMode(redB,OUTPUT);
  pinMode(greenB,OUTPUT);
  Serial.begin(9600); // Set up the serial communication.
}
void loop()
{
  lightVal = analogRead(lightsensor);
  lightValB = analogRead(lightsensorB);
  distanceVal = analogRead(distancesensor);
  distanceValB = analogRead(distancesensorB);
  Serial.println(“—–“);
  Serial.print(“lightvallue “);
  Serial.println(lightVal);
  Serial.print(“lightvalueB “);
  Serial.println(lightValB);
  Serial.print(“distancevalue “);
  Serial.println(distanceVal);
  Serial.print(“distancevalueB “);
  Serial.println(distanceValB);
 Serial.print(“state “);
 Serial.println(state);
 if (state == 0) {noPnoC ();}
 else if (state == 1) {noPoneC ();}
 else if (state == 2) {noPoneC_B ();}
 else if (state == 3) {noPtwoC ();}
 else if (state == 4) {onePnoC ();}
 else if (state == 5) {onePnoC_B ();}
 else if (state == 6) {onePoneC ();}
 else if (state == 7) {onePoneC_B ();}
 else if (state == 8) {onePtwoC ();}
 else if (state == 9) {onePtwoC_B ();}
 else if (state == 10) {twoPnoC ();}
 else if (state == 11) {twoPoneC ();}
 else if (state == 12) {twoPoneC_B ();}
 else if (state == 13) {twoPtwoC ();}
}
void noPnoC()    
{
  alloff();
  for(value = 0; value <=75; value+=5)   {analogWrite(red, value);   delay(100);}     for(value = 75; value >=0; value-=5)
  {analogWrite(red, value);
  delay(100);}
condition();
}   
void noPoneC()   
{
  alloff();
  for(value = 0; value <=50; value+=2)   {analogWrite(red, value);   delay(200);}     for(value = 50; value >=0; value-=2)
  {analogWrite(red, value);
  delay(200);}
 
condition();
}
void noPoneC_B()       
{
  alloff();
  for(value = 0; value <=50; value+=2)   {analogWrite(red, value);   delay(200);}     for(value = 50; value >=0; value-=2)
  {analogWrite(red, value);
  delay(200);}
 
 condition();
}
void noPtwoC()      
{
  alloff();
  for(value = 0; value <=50; value+=2)   {analogWrite(red, value);   delay(200);}     for(value = 50; value >=0; value-=2)
  {analogWrite(red, value);
  delay(200);}
 
 condition();
}
void onePnoC()
{
  alloff();
  for(value = 0 ; value <=180; value+=5)   {analogWrite(blue, value);   delay(30); }   for(value = 180 ; value >=0; value-=5)
  {analogWrite(blue, value);
  delay(30);}
 
condition();
}
void onePnoC_B()
{
  alloff();
  for(value = 0 ; value <=180; value+=5)   {analogWrite(red, value);   delay(30); }   for(value = 180 ; value >=0; value-=5)
  {analogWrite(red, value);
  delay(30);}
 
condition();
}

void onePoneC()
{  alloff();
  for(value =0; value <=180; value+=5)   {analogWrite(blue, value);   delay(30);}   for(value = 0; value <=255; value+=10)   {analogWrite(greenB, value);   delay(30);}     for(value = 255; value >=0; value-=10)
  {analogWrite(greenB, value);
  delay(30);}
 
  for(value = 180; value >=0; value-=5)
  {analogWrite(blue, value);
  delay(30);}
 
condition();
}
void onePoneC_B()
{  alloff();
  for(value =0; value <=180; value+=5)   {analogWrite(red, value);   delay(30);}   for(value = 0; value <=255; value+=10)   {analogWrite(greenB, value);   delay(30);}     for(value = 255; value >=0; value-=10)
  {analogWrite(greenB, value);
  delay(30);}
 
  for(value = 180; value >=0; value-=5)
  {analogWrite(red, value);
  delay(30);}
 
condition();
}
void onePtwoC()
{  alloff();
  for(value =0; value <=180; value+=5)   {analogWrite(blue, value);   delay(30);}   for(value = 0; value <=255; value+=10)   {analogWrite(greenB, value);   delay(30);}     for(value = 0; value <=255; value+=10)   {analogWrite(green, value);   delay(30);}     for(value = 255; value >=0; value-=10)
  {analogWrite(greenB, value);
  delay(30);}
    
  for(value = 255; value >=0; value-=10)
  {analogWrite(green, value);
  delay(30);}
 
  for(value = 180; value >=0; value-=5)
  {analogWrite(blue, value);
  delay(30);}
 
 condition();
}
void onePtwoC_B()
{  alloff();
  for(value =0; value <=180; value+=5)   {analogWrite(red, value);   delay(30);}   for(value = 0; value <=255; value+=10)   {analogWrite(greenB, value);   delay(30);}     for(value = 0; value <=255; value+=10)   {analogWrite(green, value);   delay(30);}     for(value = 255; value >=0; value-=10)
  {analogWrite(greenB, value);
  delay(30);}
    
  for(value = 255; value >=0; value-=10)
  {analogWrite(green, value);
  delay(30);}
 
  for(value = 180; value >=0; value-=5)
  {analogWrite(red, value);
  delay(30);}
condition();
}

void twoPnoC()
{  alloff();
  for(value =0; value <=200; value+=5)   {analogWrite(blue, value);   delay(30);}     for(value =0; value <=200; value+=5)   {analogWrite(redB, value);   delay(30);}       for(value = 200; value >=0; value-=5)
  {analogWrite(blue, value);
  delay(30);}
 
  for(value = 200; value >=0; value-=5)
  {analogWrite(redB, value);
  delay(30);}
 
condition();
}
void twoPoneC()
{  alloff();
  for(value = 0; value <=180; value+=5)   {analogWrite(blue, value);   delay(30);}     for(value =0; value <=180; value+=5)   {analogWrite(redB, value);   delay(30);}     for(value = 0; value <=255; value+=10)   {analogWrite(green, value);   delay(30);}     for(value = 255; value >=0; value-=10)
  {analogWrite(green, value);
  delay(30);}
   
  for(value = 180; value >=0; value-=5)
  {analogWrite(blue, value);
  delay(30);}
 
  for(value = 180; value >=0; value-=5)
  {analogWrite(redB, value);
  delay(30);}
 
condition();
}
void twoPoneC_B()
{  alloff();
  for(value = 0; value <=180; value+=5)   {analogWrite(blue, value);   delay(30);}     for(value =0; value <=180; value+=5)   {analogWrite(redB, value);   delay(30);}     for(value = 0; value <=255; value+=10)   {analogWrite(green, value);   delay(30);}     for(value = 255; value >=0; value-=10)
  {analogWrite(green, value);
  delay(30);}
   
  for(value = 180; value >=0; value-=5)
  {analogWrite(blue, value);
  delay(30);}
 
  for(value = 180; value >=0; value-=5)
  {analogWrite(redB, value);
  delay(30);}
 
condition();
}
void twoPtwoC()
{  alloff();
  digitalWrite(motor,HIGH);
  digitalWrite(red, HIGH);
  delay(50);
  digitalWrite(red,LOW);
  digitalWrite(red, HIGH);
  delay(50);
  digitalWrite(red,LOW);
  digitalWrite(green,HIGH);
  delay(50);
  digitalWrite(green,LOW);
  digitalWrite(blue,HIGH);
  delay(50);
  digitalWrite(blue,LOW);
  digitalWrite(greenB,HIGH);
  delay(50);
  digitalWrite(greenB,LOW); 
condition();
}

void alloff()
{
  digitalWrite(red,LOW);
  digitalWrite(green,LOW);
  digitalWrite(blue,LOW);
  digitalWrite(redB,LOW);
  digitalWrite(greenB,LOW);
  digitalWrite(motor,LOW);
}
void condition()
{
  if (distanceVal < 150 && lightVal > 80 && distanceValB < 150 && lightValB > 220) {state = 0;}
  if (distanceVal < 150 && lightVal < 80 && distanceValB < 150 && lightValB > 220) {state = 1;}
  if (distanceVal < 150 && lightVal > 80 && distanceValB < 150 && lightValB < 220) {state = 2;}   if (distanceVal < 150 && lightVal < 80 && distanceValB < 150 && lightValB < 220) {state = 3;}   if (distanceVal > 150 && lightVal > 80 && distanceValB < 150 && lightValB > 220) {state = 4;}
  if (distanceVal < 150 && lightVal > 80 && distanceValB > 150 && lightValB > 220) {state = 5;}
  if (distanceVal > 150 && lightVal < 80 && distanceValB < 150 && lightValB > 220) {state = 6;}
  if (distanceVal < 150 && lightVal > 80 && distanceValB > 150 && lightValB < 220) {state = 7;}   if (distanceVal > 150 && lightVal < 80 && distanceValB < 150 && lightValB < 220) {state = 8;}   if (distanceVal < 150 && lightVal < 80 && distanceValB > 150 && lightValB < 220) {state = 9;}   if (distanceVal > 150 && lightVal > 80 && distanceValB > 150 && lightValB > 220) {state = 10;}
  if (distanceVal > 150 && lightVal < 80 && distanceValB > 150 && lightValB > 220) {state = 11;}
  if (distanceVal > 150 && lightVal > 80 && distanceValB > 150 && lightValB < 220) {state = 12;}   if (distanceVal > 150 && lightVal < 80 && distanceValB > 150 && lightValB < 220) {state = 13;}   }[/sourcecode]

Advertisements

1 Comment »

  1. Why come up with this idea?. By the way ì still can see the cable is not very comfort? Is this already try in publìc! This creative idea, but need more progress, how about also give sense in table(cold, warm, etc) just my idea anyway. But originality always count. Good work

    Comment by Damai_uca — November 6, 2008 @ 7:38 am | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: