Making Furniture Interactive

September 17, 2007

[Dan D.W. Kang] Assignment Three: Four States

Filed under: Assignments,Dong Woo Kang,Exercise 3: Four States — dwkang @ 10:21 pm

For assignment three, I used the sensor that detects distance from the previous assignment. The programming and configuration for each of the four states has a simple code that responds to the approaching object. The code is written so that it creates an appropriate signal that represents the four different states of sleep, arousal, attract, and award.  

Sleep: The red LED is constantly lit up when there is no activity involved in front of the sensor. This red light creates the state of “sleep.” When the sensor detects an approaching object, the red LED will switch off, making the system to wake up and go into the state of “arousal.”




Arousal: Once the sensor detects the activity of a moving object, the system is fully awake and ready to respond to the movement of the object. The first response that the system shows is the three green LEDs that fade in and out a number of times. The system went into the state of “arousal.”



int analogValue0 = 0;

int analogPin0 = 0;int value = 0; int green1 = 6;                           int green2 = 5;int green3 = 3;void setup() { pinMode(analogPin0, INPUT);Serial.begin(9600);} void loop() { analogValue0 = analogRead(analogPin0);Serial.print(“Raw Sensor value;”);Serial.println(analogValue0);if (analogValue0 > 120) for(value = 0 ; value <= 255; value+=5) // fade in (from min to max)   {     analogWrite(green1, value);     analogWrite(green2, value);    analogWrite(green3, value);    delay(20); }   if (analogValue0 > 120)      for(value = 255; value >=0; value-=5)   {     analogWrite(green1, value);     analogWrite(green2, value);    analogWrite(green3, value);    delay(20);   }  if (analogValue0 < 120){  digitalWrite(green1, LOW);  digitalWrite(green2, LOW);  digitalWrite(green3, LOW);  } }

Attract: Now that the system is aware that the object is nearby, it now wants the object to come closer. The three green LEDs stop fading in/out and begin blinking consecutively, creating the state of “attract.”


int analogValue0 = 0;int analogPin0 = 0;int green1 = 6;               int green2 = 5;int green3 = 3;void setup()           {  pinMode(analogPin0, INPUT);pinMode(green1, OUTPUT); pinMode(green2, OUTPUT);  pinMode(green3, OUTPUT);  Serial.begin(9600);}void loop(){analogValue0 = analogRead(analogPin0);Serial.print(“Raw Sensor value;”);Serial.println(analogValue0);if (analogValue0 > 200)  {  digitalWrite(green1, HIGH);     delay(500);                   digitalWrite(green1, LOW);     digitalWrite(green2, HIGH);  delay(500);  digitalWrite(green2, LOW);  digitalWrite(green3, HIGH);  delay(500);  digitalWrite(green3, LOW);  }else{  digitalWrite(green1, LOW);  digitalWrite(green2, LOW);  digitalWrite(green3, LOW);}} 

Reward: When the object follows the three green lights and comes close enough to the sensor, the system will go into the state of “Reward.” During this state, the four LEDs, each with different colors, will flash rapidly.


<Code>int analogValue0 = 0;int analogPin0 = 0;int red = 13;                 int green = 6;int blue = 11;int yellow = 10; void setup()                     {  pinMode(analogPin0, INPUT);  pinMode(red, OUTPUT);       pinMode(green, OUTPUT);  pinMode(blue, OUTPUT);  pinMode(yellow, OUTPUT);  Serial.begin(9600);} void loop()                   {analogValue0 = analogRead(analogPin0);Serial.print(“Raw Sensor value;”);Serial.println(analogValue0);if (analogValue0 > 400)  {  digitalWrite(yellow, HIGH);     delay(50);                   digitalWrite(yellow, LOW);     delay(50);                   digitalWrite(green, HIGH);  delay(50);  digitalWrite(green, LOW);  delay(50);  digitalWrite(red, HIGH);  delay(50);  digitalWrite(red, LOW);  delay(50);  digitalWrite(yellow, HIGH);  delay(50);  digitalWrite(yellow, LOW);  delay(50);  digitalWrite(blue, HIGH);     delay(30);                  digitalWrite(blue, LOW);   


  }else{  digitalWrite(red, LOW);  digitalWrite(blue, LOW);  digitalWrite(yellow, LOW);  digitalWrite(green, LOW);}}       



Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

Blog at

%d bloggers like this: