User login

Powered by Drupal, an open source content management system

Theory and Practice of Tangible User Interfaces

Light Teapot

Submitted by nick on Wed, 10/08/2008 - 14:17

Description

Have some tea!

The light teapot offers an alternative to scalding tea and boring flashlights. Tip the teapot to "drip" light onto a surface, accompanied by a dripping sound. The further you tip, the faster it drips.

Light drips from an LED, with a piezo speaker providing sound. Tilt is measured by weights inside the teapot pressing on a force sensor.

Components Used

  • Arduino board
  • Teapot
  • Force sensor
  • Piezo speaker
  • Red LED
  • Foam
  • Poker chips
  • Large metal washers

Arduino Code

/* 

 * Light Tea

 * Drip some light from the teapot!

 */

 

// set pins

int fsrPin = 0;

int speakerPin = 7;

int ledPin = 13;

 

int dripSpeed = 0;

int val = 0;

 

// counter mechanism

int counter = 0;

int oldInterval = 1;

int newInterval = 1;

 

void setup() {

  pinMode(speakerPin, OUTPUT); 

  pinMode(ledPin, OUTPUT);

  beginSerial(9600);

  Serial.println("ready");

}

 

void loop() {

  digitalWrite(speakerPin, LOW);

 

  // get the pressure value

  val = analogRead(fsrPin);

 

  // set speed - process based on fsr range

  dripSpeed = val * 5;

 

  if (dripSpeed > 0) {

    newInterval = max(1, 900-dripSpeed);

    counter = max(0, ((float)newInterval / (float)oldInterval * counter) - 15);

    oldInterval = newInterval;

    

    Serial.print("interval: ");

    Serial.print(newInterval);

    Serial.print(" counter: ");

    Serial.print(counter);

    

    if (counter <= 0) {

      drip();

      counter = newInterval;

    } 

    else { 

      delay(10);

    }

  }

  

  Serial.print(" fsr: ");

  Serial.println(val);

  

}

 

void drip() {

  digitalWrite(ledPin, HIGH);// sets the LED on

  for( int i=0; i<10; i++ ) {

    digitalWrite(speakerPin, HIGH);

    delayMicroseconds(956);

    digitalWrite(speakerPin, LOW);

    delayMicroseconds(956);

  }

  digitalWrite(ledPin, LOW); // sets the LED off

}