Making Furniture Interactive

September 19, 2007

Imran’s Exercise 3 – Fill Up

Filed under: Exercise 3: Four States,Imran Sobh,Students — imranixd @ 12:21 am

The idea behind my project is using light as a virtual energy source. Using a photosensor, I shine a bright light on it and have the row of LEDs light up as an energy meter. Based on the amount of “energy” you can power something, or simply have another LED light up as long as there is energy left.

I focused on getting the circuit and programming working for this part of the project. I have the four states as separate functions and just started stringing together some of the states to get the filling up behavior.

Sleep In terms of the four states, the first one is a fading LED that gives it a sense that it is alive, but in a dormant state, I might make it fade a little slower for the final one.

Arousal For the second state, the same LED is now blinking quickly to make it seem more alert and awake. In this state it’s now possible to “fill up” the circuit with energy.

Attract This is the filling up state, where the more you fill, the more energy you get.

Reward The final state flashes like crazy once the energy is full, there is another part to this where you can drain the energy, at first it was going to be an LED, but I wanted the output to be a different type of energy.

For part two, I will venture into using a motor in the reward state, I also need to make all the transitions between the states and decide what else will trigger what happens… as well as focus on creating a physical object for it to reside inside of.


// Fading LED
// by BARRAGAN <http:> </http:>

int value = 0;                            // variable to keep the actual value
int ledpin = 9;                           // light connected to digital pin 9
//int buttonPin = ;
int state = 2; // 1=sleep, 2=attract, 3=arousal, 4=award;

int ledMeter1 = 7;
int ledMeter2 = 6;
int ledMeter3 = 5;
int ledMeter4 = 4;

int outputLED = 3;

int photoPin = 2;

int photoVal = 0;
int gasoline = 0;

void setup()
{
Serial.begin(9600);
pinMode(ledpin, OUTPUT);

pinMode(ledMeter1, OUTPUT);
pinMode(ledMeter2, OUTPUT);
pinMode(ledMeter3, OUTPUT);
pinMode(ledMeter4, OUTPUT);

pinMode(photoPin, INPUT);
pinMode(outputLED, OUTPUT);
}

void loop()
{
photoVal = analogRead(photoPin);

//Serial.println(photoVal, DEC);
Serial.println(gasoline);

if(state == 1)
{
sleep();
}
else if (state == 2)
{
attract();
}
else if (state == 3)
{
arouse();
}
else if (state == 4)
{
reward();
}

}

void sleep()
{
for(value = 0 ; value <= 255; value+=5) // fade in (from min to max)
{
analogWrite(ledpin, value);           // sets the value (range from 0 to 255)
delay(30);                            // waits for 30 milli seconds to see the dimming effect
}
for(value = 255; value >=0; value-=5)   // fade out (from max to min)
{
analogWrite(ledpin, value);
delay(30);
}
}

void attract()
{
for(int i=0; i< 3;i++)
{
analogWrite(ledpin, 255);
delay(300);
analogWrite(ledpin, 0);
delay(300);
}

if(analogRead(photoPin) > 500 &amp;&amp; gasoline &lt; 100)
{
gasoline++;
}
arouse();

}

void arouse()
{
if(gasoline == 1) {digitalWrite(ledMeter1, HIGH);}
if(gasoline == 2) {digitalWrite(ledMeter2, HIGH);}
if(gasoline == 3) {digitalWrite(ledMeter3, HIGH);}
if(gasoline == 4 ) {digitalWrite(ledMeter4, HIGH);
state=4;}
/* delay(300);
digitalWrite(ledMeter2, HIGH);
delay(300);
digitalWrite(ledMeter3, HIGH);
delay(300);
digitalWrite(ledMeter4, HIGH);
/*
delay(600);

digitalWrite(ledMeter4, LOW);
delay(300);
digitalWrite(ledMeter3, LOW);
delay(300);
digitalWrite(ledMeter2, LOW);
delay(300);
digitalWrite(ledMeter1, LOW);
delay(600);*/

}

void reward()
{

digitalWrite(outputLED, HIGH);
digitalWrite(ledpin, 0);
delay(50);
digitalWrite(outputLED, LOW);
digitalWrite(ledpin, 255);
delay(50);

}

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

Blog at WordPress.com.

%d bloggers like this: