Making Furniture Interactive

September 19, 2007

Exercise 2: Four States

Filed under: Exercise 3: Four States,Uncategorized — architk @ 10:55 pm

img_5225.jpg

img_5234.jpg

This exercise has given me time to recap everything I have learned so far in terms of programming and electrical wiring. I now need to think about and work on the fabrication part. I cleaned up the wires  which previously were all tangled up with jumper wire kit I bought from Radioshack. It was very neat and easy to understand the wiring.

In this exercise, I used photosensor again to create different states. The photosensor responds to the amount of light present in the surrounding area. I used three LEDs (Red, Yellow, Blue) and put short straws on top of the LEDs to maximize the dynamic glow in the dark. At first I struggled with the sensor to work because I put it in wrong direction. I understood now how the breadboard works and how I should place like photosensors and resistors.

Sleep is the state when there is no light turned on. Complete darkness. Attract is when the red light glows with limited light present. When I turn the switch of a lamp on, the lamp will illuminate the room and the red Led would change to yellow and to blue very fast. This is arousal. Reward is three lights blinking simultaneously.

img_5229.jpgimg_5227.jpgimg_5228.jpg

sourcecode language=’css’
int analogValue0 = 0;
int analogPin0 = 0;
int ledPinRed = 13;
int ledPinYellow = 11;
int ledPinGreen = 7;

void setup() {
  pinMode(analogPin0, INPUT);
  pinMode(ledPinRed,OUTPUT);
  pinMode(ledPinYellow,OUTPUT);
  pinMode(ledPinGreen,OUTPUT);
    Serial.begin(9600); // Set up the serial communication.
}

void loop() {
  analogValue0 = analogRead(analogPin0);
  Serial.print(“Raw Sensor value: “);
  Serial.println(analogValue0);
 
  if (analogValue0 > 400) {
    digitalWrite(ledPinGreen, HIGH);
  }
  else {
    digitalWrite(ledPinGreen, LOW);
  }
  if (analogValue0 > 125&&analogValue0 < 400) {
    digitalWrite(ledPinYellow, HIGH);
  }
  else {
    digitalWrite(ledPinYellow, LOW);
  }
  if (analogValue0 < 125) {
    digitalWrite(ledPinRed, HIGH);
  }
  else {
    digitalWrite(ledPinRed, LOW);
  }
}
/sourcecode

Advertisements

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:

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

Create a free website or blog at WordPress.com.

%d bloggers like this: