Making Furniture Interactive

September 11, 2007

Kipum Lee’s Exercise 2:

Filed under: Exercise 2: Add a Switch,Kipum Lee — Kip @ 10:08 pm

Candle | LED Switch
How the candle switch works:
As the candle’s wax burns, the paper clip, connected to ground, sinks lower and lower, finally touching the base of the candle (aluminum) which connects to to the other candle, turning the LED on the other candle. This is one way to compare the two types of “lights” as well as having a feedback mechanism, letting someone know when all the wax has been burned.

Photosensing LED:

Photosensing LED’s with a quick fade in/out:

Code was modified from an arduino tutorial with the help of fellow classmate, Jamin Hegeman:
/*
* AnalogInput
* by DojoDave
*
* Turns on and off a light emitting diode(LED) connected to digital
* pin 13. The amount of time the LED will be on and off depends on
* the value obtained by analogRead(). In the easiest case we connect
* a potentiometer to analog pin 2.
*
* http://www.arduino.cc/en/Tutorial/AnalogInput
*/

int potPin = 2; // select the input pin for the potentiometer
int ledPin = 9; // select the pin for the LED
int val = 0; // variable to store the value coming from the sensor
int value = 0; //variable to keep the actual value
int state = 0; //state variable. 0 = off.

void setup() {
pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
Serial.begin(9600);
}

void loop() {
val = analogRead(potPin); // read the value from the sensor
if(val < 90 && state == 0) { //turns on LED when light is off. change to make it turn on with light

//digitalWrite(ledPin, HIGH); // turn the ledPin on
for(value = 0 ; value = 100 && state == 1) {
//digitalWrite(ledPin, LOW); // turn the ledPin off
for(value = 255; value >=0; value-=10) // fade out (from max to min)
{
analogWrite(ledPin, value);
delay(5);
}
state = 0;
}
//delay(val); // stop the program for some time
Serial.println(val);
}

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: