Making Furniture Interactive

September 10, 2007

Candle Lamp and Switch of Frustration

Filed under: Exercise 2: Add a Switch,Ronit Slyper — Ronit @ 11:18 pm

Candle Lamp

I built a lamp that acted as a candle – you blow on it and it goes out; you blow on it again and it goes back on (don’t all candles do that? 🙂 ). Steps:

1. Build the circuit using a microphone. The microphone wasn’t sensitive enough for what I wanted – to have the lamp respond to music – so I used a preamp circuit adapted from here. Still not sensitive enough, tired of going to RadioShack, so I went with a candle theme. (A piezo element had the same problem)


2. The code kept a running average of the mic’s output, looked for a change in voltage, and toggled the LED.

/* Candle
* by Ronit

int ledPin = 13;      // led connected to control pin 13
byte val = 0;         // variable to store the value read from the sensor pin
int blowSensor = 2;
int window[100];
int avg;
int window_index;
int candle = 0;     // start out off

void setup() {
pinMode(ledPin, OUTPUT); // declare the ledPin as as OUTPUT
for (int i = 0, window_index = 0; i < 100; i++)
window[i] = 0;
Serial.begin(9600);       // use the serial port

void loop() {
val = analogRead(blowSensor);    // read the sensor and store it in the variable "val"
if (val + 20 < avg) {
if (candle==0) candle = 1; else candle = 0;
if (candle==0) digitalWrite(ledPin, LOW); else digitalWrite(ledPin, HIGH);

if (candle==0)
digitalWrite(ledPin, LOW);
digitalWrite(ledPin, HIGH);

avg -= window[window_index];
window[window_index] = val;
avg += window[window_index];
Serial.print("avg ");
Serial.println(avg, DEC);

3. House the candle.flame.jpgflame_lit.jpg

Switch of Frustration

Ever wish you could bang your head against the wall, a light would go off, and an idea would pop into your head? I accomplished the first two. An LED was connected from digital Pin 13 to ground with a break in the circuit taped to the wall. Conductive tape was unobtrusively placed on the forehead of the frustrated subject.switch_setup.jpgwall.jpgswitch_action_shot.jpg


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: