User login

Powered by Drupal, an open source content management system

Theory and Practice of Tangible User Interfaces

Whistle Sensor

Submitted by tilman on Thu, 10/09/2008 - 00:07

Assignment: Input / Output Coincidence Lab Assignment

Collaborators:

Assignment: Input / Output Coincidence Lab Assignment
Collaborators: tilman, davida

Description

The basic idea was to create a device that changes color when you wheeze. Therefore the piezo was used as analog input device that was supposed to pick up the frequency of the wheezing. Unfortunately that didn't work properly since the piezo is much more sensitive to received amplitude instead of frequency. So now when you wheeze near the ping pong ball (the LEDs as well as the piezo is hidden underneath), its color changes in four different ways according to the loudness of your wheezing or clap.

Componentes Used

  • 3 Light Emitting Diods (LED)
  • 3 Resistors
  • Wires
  • 1 Piezo
  • Ping pong ball as diffuser

Source Code

/* WhistleSensor
* ----------------
*
* The Piezo receives a sound, processes its frequency/amplitude and gives according visual output in
* 4 different colors on LEDs
*
* @author: Tilman, David
*/

int LED01 = 5;
int LED02 = 6;
int LED03 = 7;

int piezo = 0;
byte val = 0;

void setup() {
pinMode(LED01, OUTPUT);
pinMode(LED02, OUTPUT);
pinMode(LED03, OUTPUT);
beginSerial(9600);
Serial.println("ready");
}

void loop() {
val = analogRead(piezo);
if (val < 256) { //set color to red
analogWrite(LED01, 255);
analogWrite(LED02, 0);
analogWrite(LED03, 0);
}
else if (val >= 256 && val < 512) { //set color to green
analogWrite(LED01, 0);
analogWrite(LED02, 255);
analogWrite(LED03, 0);
}
else if (val >= 512 && val < 768) { //set color to blue
analogWrite(LED01, 0);
analogWrite(LED02, 0);
analogWrite(LED03, 255);
}
else { //set color to yellow
analogWrite(LED01, 155);
analogWrite(LED02, 155);
analogWrite(LED03, 0);
}
}

Images