As computing becomes more ubiquitous in our objects, designers need to be more aware of how to design meaningful interactions into electronically enhanced objects. At the University of Washington, a class of junior Interaction Design majors is exploring this question. These pages chronicle their efforts.

Tuesday, June 11, 2013

TOOTH MONSTER // Kristina & Karin

Tooth Monster from Kristina Colleen on Vimeo.







The Tooth Monster is a great way for parents to encourage kids to properly brush their teeth for two minutes and then to always floss when your done. We also created an incentive by dispensing a little treat after the Tooth Monster knows that you've already flossed your teeth! The mechanism works so that when you pull out the toothbrush to brush your teeth, a melody will play to indicate the start of two minutes. At two minutes, the second melody notifies the child that they can now put their toothbrush back in the holder. Doing so then triggers the dispensing of the floss, which the child puts it into a container when he/she's done. When the container's lid is opened, this finally triggers the dispensing of the coin as a little reward for his/her hard work :)

Links/Resources: 

http://www.arduino.cc/en/Tutorial/Melody
http://playground.arduino.cc/Learning/SingleServoExample
http://arduino.cc/en/Tutorial/Tone2
http://www.adafruit.com/blog/2009/05/19/piezo-with-an-arduino-photoresistor/

Final Code for our Tooth Monster: 

#include <Servo.h> 
#include "pitches.h"
//servo
Servo myservo;
int posNeut = 100;
int posFloss = 150;
int posCoin = 60;
//this is for the speaker
int lightPin = 0;
int lightPin2 = 1;
int brushlight = 0;
int flosslight = 0;
int piezoPin = 8;
int brushthresh = 175;
int flossthresh = 200;
// notes in the melody:
int length = 15; // the number of notes
int melody[] = {
NOTE_C4, NOTE_G3,NOTE_G3, NOTE_A3, NOTE_G3,0, NOTE_B3, NOTE_C4};
int noteDurations[] = {
4, 8, 8, 4,4,4,4,4 };
int tempo = 300; // this set up is for the
void setup() 
{
pinMode(piezoPin, OUTPUT);
Serial.begin(9600);
myservo.attach(10);
Serial.begin(9600);
//for
}
void loop () 
{
myservo.write(posNeut);
brushlight = analogRead(lightPin);
Serial.println("brushlight"); 
Serial.print(brushlight);

if (brushlight >= brushthresh) 
{ // toothbrush taken out 

for (int thisNote = 0; thisNote < 8; thisNote++) 
{
int noteDuration = 1000/noteDurations[thisNote];
tone(8, melody[thisNote],noteDuration);
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
noTone(8);
}

delay (3000); //brushing teeth

for (int thisNote = 0; thisNote < 8; thisNote++) 
{
int noteDuration = 1000/noteDurations[thisNote];
tone(8, melody[thisNote],noteDuration);
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
noTone(8);
}

brushlight = analogRead(lightPin);
Serial.println("brushlight"); 
Serial.print(brushlight);

while (brushlight >= brushthresh) //checks as long as toothbrush is out 
{
brushlight = analogRead(lightPin);
Serial.println("brushlight read til covered"); 
Serial.print(brushlight);
delay(1000); 
} 

// at this point, toothbrush is put back

myservo.write(posFloss); //dispense floss
delay(1000); //pause
myservo.write(posNeut); //return to neutral position
delay(1000); //pause

flosslight = analogRead(lightPin2);
Serial.println("flosslight"); 
Serial.print(flosslight); //reading floss light

while (flosslight < flossthresh) //container covered, 
{
flosslight = analogRead(lightPin2);
Serial.println("flosslight read til uncovered"); 
Serial.print(flosslight); 
delay(1000);
}

// container is now opened 

myservo.write(posCoin); //dispense coin
delay(1000); //pause
myservo.write(posNeut); //return to neutral position
delay(1000); //pause
}//if

}//void


The inside Mechanism: 



Trash Talk | Audio Struggles! | Sam + Willie

The keystone of Trash Talk is audio feedback. But damn it was a struggle! Initially, Willie purchased a WAVE Shield from Adafruit, which we had to completely solder and construct on our own:



This board is designed to only play .WAV files, and only from very specific FAT16 formatted SD card. It was really tough to get working, and I actually soldered one of the ICs (Integrated Circuits) in backwards, which led to it not working (shocker!). So we ordered replacement components.

But while we were waiting, we found a Seeeduino MP3 Shield at Radio Shack. We were really excited because it seemed like this would be a much easier to use board, everything came pre-soldered and would play MP3 files without us needing to convert the audio to .WAV format. But this board is has terrible documentation, the library doesn't work with current Arduino, and we couldn't make it do anything. Struggles!

But then I found the MP3 Player Shield on sparkfun! It came pre-soldered, could read mp3 files, AND there was a super simple library for it! And it worked!

So, word to the wise, if you want sound with your Arduino, then go for this MP3 Shield.

We're almost there!!!!!!!!!!

So our code is almost complete! We're getting a better idea on how/ when to use the "if" and the "While" and realized that they were not being used properly for the function we are looking to have in our last code. We've switched things around, rewrote much of the "Void Loop" and also organizing elements by providing our own names for different variables, such as "brushlight". 



#include <Servo.h>    
    Servo myservo;
    int pos = 30;

//this is for the speaker

int lightPin = 0;
int lightPin2 = 1;
int brushlight = 0;
int val2 = 0;
int piezoPin = 8;
int thresh = 




 #include "pitches.h"
int length = 15; // the number of notes
// notes in the melody:
int melody[] = {
  NOTE_C4, NOTE_G3,NOTE_G3, NOTE_A3, NOTE_G3,0, NOTE_B3, NOTE_C4};
  
int noteDurations[] = {
  4, 8, 8, 4,4,4,4,4 };
int tempo = 300; // this set up is for the 


void setup() {
 pinMode(piezoPin, OUTPUT);
Serial.begin(9600);

for (int thisNote = 0; thisNote < 8; thisNote++) {
   int noteDuration = 1000/noteDurations[thisNote];
    tone(8, melody[thisNote],noteDuration);
    int pauseBetweenNotes = noteDuration * 1.30;
    delay(pauseBetweenNotes);
    // stop the tone playing:
    noTone(8);
    
   
      myservo.attach(9);
      Serial.begin(9600);
}
  }



void loop () 
{
  brushlight = analogRead(lightPin);
  Serial.println("brushlight");


if (brushlight >= thresh) 
{ //  toothbrush taken out 
     
     for (int thisNote = 0; thisNote < 8; thisNote++) 
     {
       int noteDuration = 1000/noteDurations[thisNote];
       tone(8, melody[thisNote],noteDuration);
       int pauseBetweenNotes = noteDuration * 1.30;
       delay(pauseBetweenNotes);
       noTone(8);
     }
     
    delay (3000); //brushing teeth
    
    for (int thisNote = 0; thisNote < 8; thisNote++) 
    {
       int noteDuration = 1000/noteDurations[thisNote];
       tone(8, melody[thisNote],noteDuration);
       int pauseBetweenNotes = noteDuration * 1.30;
       delay(pauseBetweenNotes);
       noTone(8);
    }
    
    brushlight = analogRead(lightPin);
    Serial.println("brushlight");
    
    while (brushlight >= thresh)  //checks as long as toothbrush is out 
     {
      brushlight = analogRead(lightPin);
      Serial.println("brushlight"); 
     } 
  // at this point, toothbrush is put back
  
    pos = 60; //dispense floss
    myservo.write(pos);
    pos = 30; //neutral pos
    myservo.write(pos);
    
    val2 = analogRead(lightPin2);
    Serial.println("val2");
    
    while (val2 < thresh) //container covered, 
    {
    val2 = analogRead(lightPin2);
    Serial.println("val2");  
    }
    // container is now opened 
    
    pos = 5; //dispense coin
    myservo.write(pos);
    pos = 30;
    myservo.write(pos);
  
 }//if

}


Two Parts: brushing teeth phase & dispensing floss phase...how to put them together....hmm

We've come far! We have two parts within this code for the two separate phases. We're now trying to figure out how to put the two sketches together, while also experimenting with boolean breakVariables! So far, not running the way we want it to but definitely seems close....


#include <Servo.h>    
    Servo myservo;
    int pos = 5;

//this is for the speaker

int lightPin = 0;
int lightPin2 = 2;
int val = 0;
int val2 = 0;
int piezoPin = 8;
boolean breakVariable = true;



 #include "pitches.h"
int length = 15; // the number of notes
// notes in the melody:
int melody[] = {
  NOTE_C4, NOTE_G3,NOTE_G3, NOTE_A3, NOTE_G3,0, NOTE_B3, NOTE_C4};
  
int noteDurations[] = {
  4, 8, 8, 4,4,4,4,4 };
int tempo = 300; // this set up is for the 


void setup() {
 pinMode(piezoPin, OUTPUT);
Serial.begin(9600);

for (int thisNote = 0; thisNote < 8; thisNote++) {
   int noteDuration = 1000/noteDurations[thisNote];
    tone(8, melody[thisNote],noteDuration);
    int pauseBetweenNotes = noteDuration * 1.30;
    delay(pauseBetweenNotes);
    // stop the tone playing:
    noTone(8);
    
   
      myservo.attach(9);
      Serial.begin(9600);
}
  }





void loop () {
  digitalWrite(piezoPin,LOW); //toothbrush covering it
  val = analogRead(lightPin);
  Serial.println(val);

val = analogRead(lightPin);
  Serial.println(val);  
  
 if (val >=6){
   digitalWrite (piezoPin, HIGH); //turn on
   
   for (int thisNote = 0; thisNote < 8; thisNote++) {
     int noteDuration = 1000/noteDurations[thisNote];
     tone(8, melody[thisNote],noteDuration);
     int pauseBetweenNotes = noteDuration * 1.30;
     delay(pauseBetweenNotes);
     noTone(8);
   }
  delay (3000); 
  
  for (int thisNote = 0; thisNote < 8; thisNote++) {
     int noteDuration = 1000/noteDurations[thisNote];
     tone(8, melody[thisNote],noteDuration);
     int pauseBetweenNotes = noteDuration * 1.30;
     delay(pauseBetweenNotes);
     noTone(8);
   }
   
   delay (2000); 

 val = analogRead(lightPin);
  Serial.println(val);

  if (val < 6) { //if toothbrush is put back 
  pos = 60; //dispense floss
  myservo.write(pos);
     
}
}
 //THIS PHASE ENDS THE BRUSHING OF THE TEETH
  
  //NOW INTO THE PHASE OF DISPENSING THE FLOSS
  
  val2 = analogRead(lightPin2);
  Serial.println(val2); 
   
  if (val2 < 6) { //container closed
  pos = 60; //position remains
  myservo.write(pos);
  
//  val2 = analogRead(lightPin2);
//  Serial.println(val2);
  
    if (val2 >= 6) { //if container opened
      pos = 5; //dispense coin
      myservo.write(pos);
      pos = 30; //bring servo back to center
      myservo.write(pos);
    }
 }
}


Trash Talk | Physical Design and Construction | Sam + Willie

We thought that a big part of the appeal of Trash Talk would be the pure and simple joy of being surprised with fun videogame sounds. To enhance the surprise factor, we thought it would be best to use the most generic recycling can possible, and keep the technology as stealthy as possible. So we picked up a recycling bin from Amazon. We found a simple plastic pencil container at Goodwill to house the components on the rear of the can.

I used hot glue and a drill to install the IR Emitters and Sensors:







I attached the plastic housing to the rear of the can, and installed the components:



And then I installed all the bits onto the back!



Trash Talk | WiiChuck Motion Sensing | Sam + Willie

When envisioning the ideal Trash Talk interaction, Willie and I thought that it would be pretty sweet if the recycling can could know if someone's "shot" hit the outside and didn't go in; a "brick" if you will. After a little bit of research, it turns out that the WiiChuck from a Nintendo Wii can be used with Arduino to detect motion! And someone had already designed an adapter and written a library for it!!

We were able to get it up and running with both our Arduino UNO and Arduino MEGA, and blink an LED when it detected motion. Ultimately, combining the jiggle and the blink proved to be beyond the scope of my code knowledge, but here's our code for a simple jiggle + blink:

/*
 * WiiChuckDemo --
 *
 * 2008 Tod E. Kurt, http://thingm.com/
 *
 */

#include <Wire.h>
#include "nunchuck_funcs.h"

int loop_cnt=0;
int lastAccx = 0;

byte accx,accy,zbut,cbut;
int ledPin = A14;


void setup()
{
    Serial.begin(19200);
    nunchuck_setpowerpins();
    nunchuck_init(); // send the initilization handshake
 
    pinMode(ledPin, OUTPUT); //makes led on pin 13 an output pin
 
    Serial.print("WiiChuckDemo ready\n");
}

void loop()
{
    if( loop_cnt > 100 ) { // every 100 msecs get new data
        loop_cnt = 0;

        nunchuck_get_data();

        accx  = nunchuck_accelx(); // ranges from approx 70 - 182
        //accy  = nunchuck_accely(); // ranges from approx 65 - 173
        //zbut = nunchuck_zbutton();
        //cbut = nunchuck_cbutton();
         
        Serial.print("accx: "); Serial.print((byte)accx,DEC);
        //Serial.print("\taccy: "); Serial.print((byte)accy,DEC);
        //Serial.print("\tzbut: "); Serial.print((byte)zbut,DEC);
        //Serial.print("\tcbut: "); Serial.println((byte)cbut,DEC);
    }
 
    if(accx != lastAccx) {
        digitalWrite(ledPin, HIGH);
        delay(50);
        digitalWrite(ledPin, LOW);
    }
    lastAccx = accx;
 
    loop_cnt++;
    delay(1);
}

Hummingbirds in Motion - Ashley and Amy's Final Product

We all know that nature has a life of its own that unfolds when you're not looking. We wanted to make a way for people to enjoy the birds and other wildlife that frequent their home when they are not around.

We did this by choosing the smallest and fastest of the creatures in the typical backyard: the Hummingbird. Their speed provides a challenge to even the best of photographers. With our Arduino, we put speedy, motion-sensing photography into the hands of even the most amateur of photographers.

Our "Birdhouse" contains a DSLR camera, the motion sensor, and our Arduino. The Infrared Motion Sensor peers out and detects the hummingbird's motion. When motion is detected, the Arduino tells an Infrared LED to flash a pattern that mimics a camera remote control. This pattern tells the camera to take a picture.

Due to some limitations within the camera's programming, we had to add a few lines in the code that made it take a picture after 14 minutes of inactivity (to keep it from shutting off).

The camera contains an "Eye-Fi" SD card that uploads the images automatically via WiFi to a computer which then posts the photos to a Flickr account. (http://www.flickr.com/photos/97290453@N03/)


We would like to thank Andrew Hood of ArduinoDilettante and the Infrared Library of Sebastian for their significant help with our final solution.



Our final code is as follows:

iint motion_1 = 2; //put the sensor on pin 2
int light_1 = 9; //this used to be pin 13

unsigned long timecheck;

void wait(unsigned int time){
  unsigned long start = micros();
  while(micros()-start<=time){
  }
}

void high(unsigned int time, int freq, int pinLED){
  int pause = (1000/freq/2)-4;
  unsigned long start = micros();
  while(micros()-start<=time){
    digitalWrite(pinLED,HIGH);
    delayMicroseconds(pause);
    digitalWrite(pinLED,LOW);
    delayMicroseconds(pause);
  }
}

void take_picture() { 
    int _freq = 40;
    high(2000,_freq,light_1);
    wait(27830);
    high(390,_freq,light_1);
    wait(1580);
    high(410,_freq,light_1);
    wait(3580);
    high(400,_freq,light_1);
    timecheck = millis();
}

void setup(){
  // This runs once on boot up.  Put stuff here that runs at 
  // start up and then not again
  pinMode (motion_1,INPUT);
  pinMode (light_1, OUTPUT);
  take_picture();
  delay(1000); // allow motion sensor to settle down
}

void loop (){
  if ( HIGH == digitalRead(motion_1)){
    take_picture();
    delay(5000);
  } else {
    delay(500);  // wait a half second between checks of motion sensor
  }

  if (millis() - timecheck > 840000) { //14 minutes=840000
    take_picture();
  }
}