User login

Powered by Drupal, an open source content management system

Theory and Practice of Tangible User Interfaces

Lab 5: I/O Coincidence - Wallace the Angry Muffin

Submitted by Seth Horrigan on Tue, 10/07/2008 - 09:14

Assignment: Input / Output Coincidence Lab Assignment

Collaborators:

 

 

Description

Wallace is a muffin who protests when you try to eat him. I had initially intended to use two forms of input (FSR and photocells) to make Wallace react to both when someone reached for him and when someone picked him up, but due to the fragile state of the non-soldered connections, I restricted the input to photocells alone. Also, I initially intended to use resistors in parallel to increase the volume as well as the pitch as Wallace's pight deepened, but it seems that pins that have "LOW" written to them act as a ground so that idea is impossible without multiple Piezo speakers.

 

In the end, Wallace's "eyes" glow brighter, and he goes from "growling" to "screaming" if you try to pick him up. Sadly, you cannot experience the sound from the pictures. Happily, Andy's project reminded me that I can just upload a photo to webshots and inline it. I will also try to bring the setup intact to class on Thursday.

 

Components Used

  • 1 photocell
  • 1 Arduino board
  • 1 generic solderless breadboard
  • 2 rubber bands to secure the Arduino board to the breadboard
  • wires
  • 1 blue LED
  • 1 green LED
  • 1 Piezo speaker
  • 1 10k Ohm resistor
  • 1 220 Ohm resistor

Images and Video

Wallace the Angry Muffin in action

 

This is Wallace resting comfortably.

As you reach for him, he growls and his eyes glow a little.

If you grab him, his eyes glow brightly and he screams.

Arduino Code

/* Angry Muffin
* ------------
*
* Light up "eyes" and play angry buzzing when
* a person tries to pick up the muffin.
*
* Created by Seth Horrigan
*/

int eyesPin = 6;
int sndPin = 2;
int sensorPin = 0; // select the input pin for the sensor

int maxVal = 950; //Set these based on lighting
int minVal = 600;
int increment = 0;

void setup() {
pinMode(eyesPin, OUTPUT);
pinMode(sndPin, OUTPUT);
beginSerial(9600);
increment = (maxVal - minVal) / 4;
Serial.println("ready");
}

void loop() {
int input = analogRead(sensorPin); // read the value from the sensor, 0-1023
if(input > maxVal){
maxVal = input;
increment = (maxVal - minVal) / 4;
}else if(input < minVal){
minVal = input;
increment = (maxVal - minVal) / 4;
}

int brightness = min(abs(input - maxVal) * 0.80, 255); //
if(brightness > 25){
analogWrite(eyesPin, brightness); // analogWrite (dimming the LED) can be between 0-255
}else{
analogWrite(eyesPin, 0);
}

int tone = 0;
if(input < (maxVal - 4 * increment)){
tone = 75;
}else if(input < (maxVal - 3 * increment)){
tone = 1000;
}else if(input < (maxVal - 2 * increment)){
tone = 3000;
}else if(input < (maxVal - increment)){
tone = 6000;
}
if(brightness > 25){
digitalWrite(sndPin, HIGH);
delayMicroseconds(tone);
digitalWrite(sndPin, LOW);
delayMicroseconds(tone);
}

//Serial.println(input);
/*Serial.print(input); // writing the value to the PC via serial connection
Serial.print(" ");
Serial.print(brightness);
Serial.print(" ");
Serial.println(tone);*/
}