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.

Thursday, June 13, 2013

Trash Talk | Game On | Sam + Willie

Welcome to the final Trash Talk blog post.

Over 10 weeks Willie and I were able to get more or less up to speed on Arduino code, source and construct an Arduino enabled recycling bin, and get it to respond to a situation in the environment. Trash Talk is designed to make the mundane activity of recycling more surprising and delightful. And we've succeeded. Trash Talk can detect when you make a basket, and play a randomized sound effect from NBA Jams. Unfortunately we weren't able to resolve the code enough to include wiichuck shaking functionality, due to the limited scope of our knowledge and time. But all in all, we're extremely proud of what we've accomplished and learned over the course of this project.

Here's our short film about Trash Talk:


Introducing Trash Talk from Sam Cook on Vimeo.




Here's a list of sources and resources that we used in our project:

WAVE Shield - http://www.ladyada.net/make/waveshield/
IR Sensing - http://forum.arduino.cc/index.php?topic=94690.0
MP3 Player Shield - https://www.sparkfun.com/products/10628
WiiChuck - http://todbot.com/blog/2008/02/18/wiichuck-wii-nunchuck-adapter-available/
WiiChuck + Arduino Mega - http://forum.arduino.cc/index.php/topic,21723.0.html

Here's our (delightful) code:

// this is an LED blink sketch with calibration for all 3 Sensors
// hopefully it works

#include <SPI.h>
#include <SdFat.h>
#include <SdFatUtil.h> 
#include <SFEMP3Shield.h>

SdFat sd;
SFEMP3Shield MP3player;

const int sensor1 = A0; // analog input pin -- Detector (clear)
const int sensor2       = A1;
const int sensor3       = A2;
const int emitterPin = 14; // digital output pin -- Emitter/dark)
const int signalPin     = A15;   // signal pin setup

// variables:
int sensor1Val   = 0;         // the sensor value
int sensor1Max   = 0;         // maximum sensor value

int sensor2Val   = 0; 
int sensor2Max   = 0;

int sensor3Val   = 0;
int sensor3Max   = 0;



// a function for making the signalPin blink
void blink() {
  digitalWrite(signalPin, HIGH);
  delay(200);
  digitalWrite(signalPin, LOW);
}

void success() {
  int x = random(1, 5);
  switch (x) {
    case 1:
      MP3player.playTrack(1);
      break;
    case 2:
      MP3player.playTrack(2);
      break;
    case 3:
      MP3player.playTrack(3);
      break;
    case 4:
      MP3player.playTrack(4);
      break;
    case 5:
      MP3player.playTrack(5);
      break;
  }
}



// Sets up the Calibrations
void setup() {
  
  Serial.begin(19200);
  
  //gets the MP3 Shield Fired Up
  sd.begin(SD_SEL, SPI_HALF_SPEED);
  MP3player.begin();
  MP3player.setVolume(0,0);
  
  // turn on LED to signal the start of the calibration period:
  pinMode(signalPin, OUTPUT);
  digitalWrite(signalPin, HIGH);
  
  // Turns on my IR emitters
  pinMode( emitterPin, OUTPUT );
  digitalWrite( emitterPin, HIGH );
  
  Serial.println("beginning calibration");
  // calibrate Sensors during the first three seconds 
  while (millis() < 3000) {
    
    sensor1Val = analogRead(sensor1);
    //Serial.println(sensor1Val);
    sensor2Val = analogRead(sensor2);
    //Serial.println(sensor2Val);
    sensor3Val = analogRead(sensor3);
    //Serial.println(sensor3Val);
    
    // records the maximum sensor value
    if (sensor1Val > sensor1Max) {
      sensor1Max = sensor1Val;
    }
    
    if (sensor2Val > sensor2Max) {
      sensor2Max = sensor2Val;
    }
    
    if (sensor3Val > sensor3Max) {
      sensor3Max = sensor3Val;
    }
  }
  
  Serial.print("Sensor1 Max: ");
  Serial.println(sensor1Max);
  Serial.print("Sensor2 Max: ");
  Serial.println(sensor2Max);
  Serial.print("Sensor3 Max: ");
  Serial.println(sensor3Max);
  Serial.println("Done Calibrating");
  
  // signal the end of the calibration period
  digitalWrite(signalPin, LOW);
  
}


//where the magic happens
void loop() {
  
  
  
  // read the sensors
  sensor1Val = analogRead(sensor1);
  Serial.println(sensor1Val);
  sensor2Val = analogRead(sensor2);
  Serial.println(sensor2Val);
  sensor3Val = analogRead(sensor3);
  Serial.println(sensor3Val);
  
  
  
  //IR sensing Action Statement
  if(sensor1Val <= (sensor1Max - 4)) {
    blink();
    success();
    Serial.println("sensor1 actuation");
  }
  
  if(sensor2Val <= (sensor2Max - 4)) {
    success();
    Serial.println("sensor2 actuation");
  }
  
  if(sensor3Val <= (sensor3Max - 4)) {
    success();
    Serial.println("sensor3 actuation");
  }
  
  //Serial.print("sensor values = ");
  //Serial.print(sensor1Val + ", ");
  //Serial.print(sensor2Val + ", ");
  //Serial.println(sensor3Val);
  delay(5);
}

No comments:

Post a Comment