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

Trash Talk | IR beam testing | Sam + Willie

Willie and I have decided on building a recycling can that can detect "shots" (when the paper you throw at it goes into the can), and provides audio feedback with sound effects from NBA Jams. The first step was to think about how we could detect these things going in. Infrared sensing made the most sense. We bought sensor and emitter pairs from Radio Shack which worked really well. We were also really surprised with how much stuff Radio Shack had to cater to the Arduino tinkerer. Definitely an under-rated resource.

Anyways, we got the IR pairs to detect and set off a normal LED. SWEET! Basically, we watched the Serial monitor for values, and then manually set a threshold.

Here's a photo:
















Here's our code for the simple IR detections:

//
// IR_Sensors_2.ino -- play the current value of an IR Sensor on a 5v speaker, adjusting
// from a base pitch of C3 (220hz)
//
// Dervied from http://arduino.cc/forum/index.php?topic=94690.0
//
// Note: Detector is clear, emitter is dark
//
//

// Constants

const int IR_IN_ANALOG_PIN = 2; // analog input pin -- Detector (clear)
const int IR_OUTPUT_PIN = 2; // digital output pin -- Emitter/dark)
const int LEDsignalPin          = 13;   // signal pin setup

const String INTRO = "Starting...";

// IR level values

int irLevel = 0; // variable to store the value read from input pin
int minIRLevel = 1000;
int maxIRLevel = 0;
int lastIRLevel = 0;
int irTone = 0;

bool firstLoop = true;
bool debug = true; // Set false to turn off Serial tracing
bool newRange = false;


//
// setup
//
void setup() {

// Set up the output LED

pinMode( IR_OUTPUT_PIN, OUTPUT );
digitalWrite( IR_OUTPUT_PIN, HIGH ); // Turns on the emitter
        pinMode( LEDsignalPin, OUTPUT );    //sets signal LED to off

// Turn on tracing

if ( debug ) {
Serial.begin( 9600 );
}
}


//
// loop -- show the current input to the detector.  Sense and highlight changes to the observed
// min, max and avg values of the signal
//
void loop() {

// read value of analog input
     
irLevel = analogRead( IR_IN_ANALOG_PIN );

// Play its value

//irTone = NOTE_C3 + irLevel;
//tone( SPKR_PIN, irTone );

// print header & initial irLevel

if ( firstLoop == true ) {
if ( debug ) {
Serial.println( INTRO );
Serial.print( "initial irLevel = " );
Serial.println( irLevel );
}
firstLoop = false;
}

// Check if irLevel changed

newRange = false;
if ( irLevel < 60) {
                digitalWrite (LEDsignalPin, HIGH);
                delay(50);
                digitalWrite (LEDsignalPin, LOW);
        }

        if ( irLevel != lastIRLevel ) {

// Trace the new IR level

if ( debug ) {

// Print the level

Serial.print( "irLevel = " );
Serial.print( irLevel );

// Print increase/decrease

if ( irLevel > lastIRLevel ) {
Serial.print( " +++" );
} else {
Serial.print( " ---" );
}
}

// Save new minimum

if ( irLevel < minIRLevel ) {
if ( debug ) {
Serial.print( " new MIN" );
}
newRange = true;
minIRLevel = irLevel;
}

// Save new maximum

if ( irLevel > maxIRLevel ) {
if ( debug ) {
Serial.print( " new MAX" );
}
newRange = true;
maxIRLevel = irLevel;
}

// Finish the trace line

if ( debug ) {
Serial.println( "" );
}

// Print new range

if ( newRange ) {
if ( debug ) {
Serial.print( "Range: [ " );
Serial.print( minIRLevel );
Serial.print( ", " );
Serial.print( maxIRLevel );
Serial.println( " ]" );
}
}

// Save the irLevel

lastIRLevel = irLevel;

// wait half a second

if ( debug ) {
delay( 5 );
}
}


}


We later added a calibration to the IR setup, so that it would calibrate itself to the surrounding IR levels, and then watch for those to be changed. This means we can turn it on in any situation and it will adjust to the ambient about of IR light. Here's the code for that:

// this is an LED blink sketch with calibration for just one Sensor


const int sensorOne = A0; // analog input pin -- Detector (clear)
const int sensorTwo     = A1;
const int sensorThree   = A2;
const int emitterPin = 2; // digital output pin -- Emitter/dark)
const int signalPin  = 13;   // signal pin setup

// variables:
int sensorValue   = 0;         // the sensor value
int sensorMin     = 1023;        // minimum sensor value
int sensorMax     = 0;           // maximum sensor value


void blink() {
  digitalWrite(13, HIGH);
  delay(300);
  digitalWrite(13, LOW);
}

void setup() {
  // turn on LED to signal the start of the calibration period:
  pinMode(signalPin, OUTPUT);
  digitalWrite(signalPin, HIGH);

  pinMode( emitterPin, OUTPUT );
  digitalWrite( emitterPin, HIGH ); // Turns on the emitter

  // calibrate during the first three seconds
  while (millis() < 3000) {
    sensorValue = analogRead(sensorOne);

    // record the maximum sensor value
    if (sensorValue > sensorMax) {
      sensorMax = sensorValue;
    }

    // record the minimum sensor value
    if (sensorValue < sensorMin) {
      sensorMin = sensorValue;
    }
  }

  // signal the end of the calibration period
  digitalWrite(signalPin, LOW);
  Serial.begin(9600);
}

void loop() {
  // read the sensor:
  sensorValue = analogRead(sensorOne);

  // apply the calibration to the sensor reading
  sensorValue = map(sensorValue, sensorMin, sensorMax, 0, 255);

  // in case the sensor value is outside the range seen during calibration
  sensorValue = constrain(sensorValue, 0, 255);

  if(sensorValue <= (sensorMax - 8)){
    digitalWrite(13, HIGH);
    delay(300);
    digitalWrite(13, LOW);
  }

  Serial.print("sensor value = ");
  Serial.println(sensorValue);

  delay(5);
}

Randy & Charlie: Noyse

Concept Video

Description

Our project tackled the issue of sound sensing regarding Deaf and hard of hearing individuals. In describing our device we want to avoid calling it a hearing aid, because it in no way aids in hearing in the conventional sense. Rather, it provides a nuance form of sound feedback through haptics via vibration motors which can be taken advantaged by both the hearing and deaf. The device, worn around the neck, is embedded with four microphone-vibration motors pairs distributed evenly around it's perimeter. Sound that is registered by the microphones triggers their respective vibration motor. The strength of the vibration is proportional to the amplitude of the registered sound. Essentially, the user can feel the intensity and directionality of incoming sound. To combat issue of ambient sound, the device samples and retains the amplitude of the previous ten seconds, averages the ten samples, and sets it as the threshold at which new incoming sound must register in order to trigger vibrations.

Code


// The analogue input pins each microphone is plugged into.
const int electret1 = 0;  
const int electret2 = 1;
const int electret3 = 2;
const int electret4 = 3;

// The analogue output pins each vibration motor.
const int vibration1 = 10;  
const int vibration2 = 6;
const int vibration3 = 5;
const int vibration4 = 3;

// Variable to store the value read from the sensor pins.
int sensorReading1 = 0;     
int sensorReading2 = 0;
int sensorReading3 = 0;
int sensorReading4 = 0;

// The queue of running averages for each microphone to set threshold.
int sensorMax1[10];
int sensorMax2[10];
int sensorMax3[10];
int sensorMax4[10];

// Queue to temporarily store data.
int temp[10];

// The minimum.
int sensorMin = 1023;

// The threshold that needs to be surpassed to register.
int threshold1;
int threshold2;
int threshold3;
int threshold4;

// Keep track of time to take samples every instance.
int time;

// SETUP
void setup() {
  
  // Use the serial port 57600 to read faster than 9600.
  Serial.begin(57600);  

  // Set the vibration motors as output.
  pinMode(vibration1, OUTPUT);
  pinMode(vibration2, OUTPUT);
  pinMode(vibration3, OUTPUT);
  pinMode(vibration4, OUTPUT);
  
  delay(2000);
  
  // Record time it took to get here.
  time = millis();
  
  Serial.print("Time: ");
  Serial.println(time);
  // For ten seconds...
  for (int i = 0; i < 10; i++) {
    // Every 5 seconds, add a microphone reading to each microphone reading queue.
    Serial.print("Passed: ");
    Serial.println(millis() - time);
    
    sensorReading1 = analogRead(electret1);   
    push(sensorMax1, sensorReading1);
    
    sensorReading2 = analogRead(electret2); 
    push(sensorMax2, sensorReading2);
    
    sensorReading3 = analogRead(electret3); 
    push(sensorMax3, sensorReading3);;
    
    sensorReading4 = analogRead(electret4); 
    push(sensorMax4, sensorReading4);
    delay(1000);
  }
  
  Serial.print("Setup sensor1:");
  Serial.println(sizeof(sensorMax1));
  
  Serial.print("Setup sensor2:");
  Serial.println(sizeof(sensorMax2));
  
  Serial.print("Setup sensor3:");
  Serial.println(sizeof(sensorMax3));
  
  Serial.print("Setup sensor4:");
  Serial.println(sizeof(sensorMax4));
  
  // Set the threshold for each microphone as the average of the queue.
  Serial.println("Lets begin.");
  averageMicrophones();
}


// THE LOOP
void loop() {
  // For stability, start out with low on all vibration motors.
  digitalWrite(vibration1, LOW);
  digitalWrite(vibration2, LOW);
  digitalWrite(vibration3, LOW);
  digitalWrite(vibration4, LOW);
  
  // Read the sensor and store it in a variable.
  sensorReading1 = analogRead(electret1);
  sensorReading2 = analogRead(electret2);
  sensorReading3 = analogRead(electret3);
  sensorReading4 = analogRead(electret4);

  // if the sensor reading is greater than the threshold:
  if (sensorReading1 >= threshold1) {
    Serial.print("Mic1: ");
    Serial.print(sensorReading1-threshold1);
    Serial.print("    ");
    if (sensorReading1-threshold1 > 10) {
      digitalWrite(vibration1, HIGH);
    }
  } else {
    Serial.print("Mic1: 0    ");
  }
  
  if (sensorReading2 >= threshold2) {
    Serial.print("Mic2: ");
    Serial.print(sensorReading2-threshold2);
    Serial.print("    ");
    if (sensorReading2-threshold2 > 10) {
      digitalWrite(vibration2, HIGH);
    }
  } else {
    Serial.print("Mic2: 0    ");
  }
  
  if (sensorReading3 >= threshold3) {
    Serial.print("Mic3: ");
    Serial.print(sensorReading3-threshold3);
    Serial.print("    ");
    if (sensorReading3-threshold3 > 10) {
      digitalWrite(vibration3, HIGH);
    }
  } else {
    Serial.print("Mic3: 0    ");
  }
  
  if (sensorReading4 >= threshold4) {
    Serial.print("Mic4: ");
    Serial.print(sensorReading4-threshold4);
    Serial.print("    ");
    Serial.print("\n");  
    if (sensorReading4-threshold4 > 10) {
         digitalWrite(vibration4, HIGH);
    }
  } else {
    Serial.print("Mic4: 0    ");
    Serial.print("\n");  
  }
  
  // Every second, take a reading and use it to adjust the average.
  if (millis() % 1000 == 0) {
    // Put in new data.
    push(sensorMax1, sensorReading1);
    push(sensorMax2, sensorReading2);
    push(sensorMax3, sensorReading3);
    push(sensorMax4, sensorReading4);
    // Average the data.
    averageMicrophones();
  }
  
  delay(2);  // Better for Processing showing data
}


// Averages all the microphone readings.
void averageMicrophones() {
  
  // Average the recordings of micrphone 1.
  int sum = 0;
  for (int i = 0; i < 10; i++) {
     sum = sum + sensorMax1[i];
  }
  threshold1 = sum / 10;
  
  // Average the recordings of micrphone 2.
  sum = 0;
  for (int i = 0; i < 10; i++) {
     sum = sum + sensorMax2[i];
  }
  threshold2 = sum / 10;
  
  // Average the recordings of micrphone 3.
  sum = 0;
  for (int i = 0; i < 10; i++) {
     sum = sum + sensorMax3[i];
  }
  threshold3 = sum / 10;
  
  threshold4 = sum / 10;
  
  // Average the recordings of micrphone 4.
  sum = 0;
  for (int i = 0; i < 10; i++) {
     sum = sum + sensorMax4[i];
  }
  threshold4 = sum / 10;
}

References

Brains Of Deaf People Rewire To "Hear" Music. How the brain of a Deaf individual rewires to feel vibrations. Arduino listens to electret microphone. How to make an Arduino work with a elecret microphone. Professor Lance Forshay. Interviewed with Lance Forshay.

Dan | Stephen //Sensors


For our project, we need the Arduino to read how much paper is being pulled off the roll, so that we can get the user to use less of it. We scoured the internet for different sensors that we could use for this. One idea we had was to count the rotations of the paper roll. The problem with this is that the circumference of the paper roll, gets smaller as paper runs out, meaning we'd have to do some crazy math to calculate the right amount being used. It would also vary, depending on the brand of paper and the ply used. Back to the drawing board, Dominic suggested we use a computer mouse. This would sit right on the paper, and count sheets as they are pulled underneath it. This was a great idea, because it didn't involve any math and the parts were readily available at the local Goodwill stores. I bought two mice, one optical and a old school rollerball mouse with a PS/2 connection. the PS/2 standard has 6 pins that can directly interface with an Arduino board. The biggest headache we faced with this was the lack of usable code libraries. We found dozens of user created methods for using a computer mouse like what we were doing, but all of their solutions had code that was supported in older versions of Arduino, going back to the alpha version 0022.





We were able to get the mouse to connect but could not find any compatable code or get any useful readings. 

The next sensor we tried an infared emitter and detector. We set up a laser cut wheel with three holes, every time the laser was broken three times represented a full rotation of the toilet paper roll. We were able to get the sensors to respond and count but not as regularly as we wanted and we could not figure out what it was that was keeping us from getting to the solution. The code we used looked like this:
the process looked like this:




Friday Night Tights: All Wound Up — Mallika Simone, Sarah Churng



Boards:





Visual compendium:


Friday Night Tights from sarah churng on Vimeo.

The Anatomy:

The device: 

Friday Night Tights is wearable technology that addresses the dangers of drunk walking. Many Americans have a false sense of security that, by avoiding driving under the influence, they are safe to walk while intoxicated. Yet fatalities are in fact high among drunk pedestrians who walk into traffic.

The system houses an Arduino device inside a fanny pack attached to the tights' hip, and runs wires down to pressure sensors which slip into the wearer's shoes.

When the system detects walking patterns that indicate severe levels of intoxication, it emits a subtle LED light up in the pouch, and syncs wirelessly with an Android phone, to send a text message to a predesignated friend or cab company of the wearer's whereabouts.


The algorithm: 

We define an inebriate's type of imbalance as marked by quick, light steps, followed rapidly by long, heavy compensating steps. 2 warnings are allowed before, on the 3rd round, the response is triggered.

When the Arduino has access to video output, it can provide serial monitoring results like:


the device's serial output 




The Code:

// Our algorithm detects drunk walking by tracking sudden shifts of imbalance.
// We define an inebriate's type of imbalance as marked by quick, light steps, 
// followed rapidly by long, heavy compensating steps. 2 warnings are allowed 
// before, on the 3rd round, the response is triggered.

// LIBRARIES
#include <QueueArray.h>                                 // FIFO stack 

// ANALOG DATA: Left Foot
const int analogInPin1 = A0;                            // Force Pressure Sensor at A0
//const int analogOutPin1 = 9;                          // LED at variable pin 10
int sensorValue1 = 0;                                   // value from variable sensor
int LeftValue = 0;                                      // value from output to analog out

// ANALOG DATA: Right Foot
const int analogInPin2 = A1;                            // Force Pressure Sensor at A1
//const int analogOutPin2 = 10;                         // LED at variable pin 9
int sensorValue2 = 0;                                   // value from variable sensor
int RightValue = 0;                                     // value from output to analog out


// QUEUE: a custom First-In-First-Out array
class QueueNode
{
  public:
    QueueNode(int val, QueueNode* next)
    {
     _val = val;
     _next = next;
    } 
    
    int _val;
    QueueNode* _next;
};

class Queue
{
    public:
      Queue()
      {
        head = NULL; 
      }
      
      void Append(int val)                         // ~ QueueArray.push()
      {
        QueueNode* qn = new QueueNode(val, head);
        head = qn;
      };
      
      void Clear()                                 // ~ QueueArray.clear()
      {
        QueueNode* cur = head;
        head = NULL;
        while (cur != NULL)
        {
         QueueNode* next = cur->_next;
         delete cur;
         cur = next;
        }
      }
      
      QueueNode* Pull()                            // ~ QueueArray.pop()
      {
        QueueNode* cur = head;
        head = NULL;  
        QueueNode* next = cur->_next;
        cur = next;
        delete cur;
        return cur;
      }
      
      float Average()                              // return a numerical average 
      {
        int cnt = 0;
        int sum = 0;
        QueueNode* cur = head;
        while (cur != NULL)
        {
          cnt++;
          sum += cur->_val;
          cur = cur->_next;
        }
        
        if (cnt == 0)
          return 0.0;
        else
          return (float)sum/(float)cnt;
      }
      
      int Count()                                 // return the total items in Queue
      {
        int cnt = 0;
        QueueNode* cur = head;
        while (cur != NULL)
        {
          cnt++;
          cur = cur->_next;
        }
        return (int)cnt;
      }

    private:
      QueueNode* head;
};



// GLOBALS
Queue PressureQ = Queue();                 // Queue of current step's pressure values 
Queue DrunkTrackerQ = Queue();             // Instances of drunk-like behavior before drunk alarm goes off.

float currPressureAvg = 0.00;              // float of current step's average pressure
float prevPressureAvg = 0.00;              // float of previous step's average pressure

int currPace = 0;                          // int of current step's pace length
int prevPace = 0;                          // int of previous step's pace length

int loopNum = 0;
int drunkSteps = 3;
int warnBlinks = 0;

//LED OUTS:
int ledPin1 = 9;
int ledPin2 = 10;



// DETECT: This function collects the pressure and timing of each step. One step is the combination of pressure that is greater than 0 followed by 0 pressure. Pacing is measured as the duration of each step.
void DetectStep(int outputValue)
{
  if ( outputValue != 0 )                              // Record pressure values during a foot step
  {
    PressureQ.Append(outputValue);
    Serial.print("\tpressure: \t");
    Serial.println(outputValue);
  }
  else                                                  // At the end of the footstep, calculate the step's average pressure
  {
    currPace = PressureQ.Count();                       // And record the footstep's length
    currPressureAvg = PressureQ.Average();          
    
    PressureQ.Clear();
    
    Serial.print("\tpressure average: \t");
    Serial.println(currPressureAvg);
    Serial.print("\tpace: \t");
    Serial.println(currPace);
  }
}

// FLAG: Function flags instances of a very short and light step being followed immediately by a long and heavy step
void Flag( float currPressureAvg, int currPace )
{
  if ( (prevPace >= (currPace/2)) && ( prevPace != 0 ) )
  {
    if ( currPressureAvg >= (prevPressureAvg/2) )
    {
      drunkSteps--;                                      // Give a set number of warnings
      warnBlinks++;
    
      Serial.print("you kinda drunk...but we gonna give you ");
      Serial.print(drunkSteps);
      Serial.println(" more chances.");
      
      // Blink with # blinks = # warnings
      for (int i=0; i++; i<warnBlinks){
        digitalWrite(ledPin1, HIGH);                     // Turn the LED on (HIGH is the voltage level)
        delay(750);                                      // Wait
        digitalWrite(ledPin1, LOW);                      // Turn the LED off by making the voltage LOW
        delay(750);                                      // Wait
      }
    }
  }
}

// RESPOND: This function calls DETECT and FLAG and triggers a response if no warnings are left.
void respond(int outputValue)
{
  pinMode(ledPin1, OUTPUT);                             // LED pins to output
  pinMode(ledPin2, OUTPUT);

  DetectStep(outputValue);                              // Detect steps 
  Flag(currPressureAvg, currPace);                      // Flag for drunkenness
  prevPressureAvg = currPressureAvg;                    // Step forward on pressure 
  prevPace = currPace;                                  // Step forward on pace
    
  // RESPONSE NECESSARY
  if (drunkSteps == 0)
  {
    // Just blink like cray
    Serial.println("YEAH YOU SHITFACED...LEDs and whatever");
    digitalWrite(ledPin1, HIGH);                        // Turn the LED on (HIGH is the voltage level)
    delay(500);                                         // Wait for half a second
    digitalWrite(ledPin1, LOW);                         // Turn the LED off by making the voltage LOW
    delay(500);                                         // Wait for half a second
  }
}


// SETUP WITH SERIAL MONITORING
void setup(){ 
  Serial.begin(9600);                                   
}
  

// MAIN LOOP: 
void loop()
{
  QueueArray <int> LeftRight;
  Serial.print("loop: \t");
  Serial.println(loopNum);

  loopNum++;
  
  // READ: analog values
  sensorValue1 = analogRead(analogInPin1);              // Read in input from left foot
  LeftValue = map(sensorValue1, 0, 256, 0, 50);         // Map the lower-bound 0-256 to the range 0-50
  //analogWrite(analogOutPin1, LeftValue);              // Change the analog out value

  sensorValue2 = analogRead(analogInPin2);              // Read in input from right foot
  RightValue = map(sensorValue2, 0, 256, 0, 50);        // Map the lower-bound 0-256 to the range 0-50
  //analogWrite(analogOutPin2, RightValue);             // Change the analog out value
  
  LeftRight.push(LeftValue);
  LeftRight.push(RightValue);

  //while ( !LeftRight.isEmpty() )
  //{
    int outputValue = LeftRight.pop();
    respond(LeftRight.pop());
  //}

  delay (1000);                                         // Half second cycles
}


References:

Traffic Safety Facts 2009 Data. U.S. Department of Transportation, National Highway Traffic Safety Administration

The Perils of Drunk Walking: A New Marketplace Podcast

Freakonomics: What Went Right? Responding to Wrong-Headed Attacks

Flexiforce Sensors Screening Athlete's Feet at the Special Olympics. These are the force pressure sensors we researched and used.


Android Bluetooth to Arduino. For the text messaging response.

Investigator: Breathalyzer found to be inaccurate, unreliable. An investigative article on the inaccuracies of breathalyzers, which contributed to our decision to stay away from using alcohol breath detection.


Flexiforce Quickstart Guide. For working with flexiforce and Arduino

QueueArray. library for FIFO queue.

C++

Artefact Wearable Tech Movement. The wearable tech movement look and appeal that inspired our attention to chic over kitsch.

Look Around You. The BBC parody that inspired the direction of our video. 

Dan | Stephen //Artefact

The physical artifact that houses our Arduino is a toilet paper dispenser designed for a public restroom space. We wanted to house the Arduino to keep it concealed from direct view but can be viewed for the curious/suspicious user. By using curves and we wanted to reference the shape of a roll of toilet paper and make it easy for the user to see how much paper is on the roll as well as see how much they are using.

We wanted to keep it self contained in one unit so we designed it by using laser cut acrylic, heating and bending it to hold the roll and the Arduino. We sanded it and then applied several coats of white paint to finish it off.







Monday, June 10, 2013

DAN | STEPHEN

This informational poster describes the interaction reasoning behind the direction we chose for our project and how the interactions will strive to push for a social change. It also outlines the steps of code to create the interaction as well as a map that aligns the components to produce a reaction that the user will respond to.