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.

Saturday, May 18, 2013

Breakthrough With Serial Communication Mason/Nick



It may not look like much but this is the result of quite a few frustrating hours. One the hardware side it is a led sure but what is  more important is what is turning that led on. This light is controlled by a text file, and a very simple one at that THe main problem that we had was getting a serial communication between processing and the Arduino. That has been solved.  The main issue was file conventions for macs

Our next steps will be to apply this to the weather report file we have and code some motors.



Processing code below







import processing.serial.*;

Serial comPort;
int counter=0; // Helps to keep track of values sent.
int numItems=0; //Keep track of the number of values in text file
boolean sendStrings=false; //Turns sending on and off
StringLoader sLoader; //Used to send values to Arduino

void setup(){
 comPort = new Serial(this, Serial.list()[6], 9600);
 background(255,0,0); //Start with a Red background
}

void draw(){
}


void mousePressed() {
 //Toggle between sending values and not sending values
 sendStrings=!sendStrings;

 //If sendStrings is True - then send values to Arduino
 if(sendStrings){
 background(0,255,0); //Change the background to green

 /*When the background is green, transmit
 text file values to the Arduino */
 sLoader=new StringLoader();
 sLoader.start();
 }else{
 background(255,0,0); //Change background to red
 //Reset the counter
 counter=0;
 }
}



/*============================================================*/
/* The StringLoader class imports data from a text file
 on a new Thread and sends each value once every half second */
public class StringLoader extends Thread{

 public StringLoader(){
 //default constructor
 }

 public void run() {
 String textFileLines[]=loadStrings("/Users/Nick/Desktop/srialblink/3.txt");
 String lineItems[]=splitTokens(textFileLines[0], ",");
 numItems=lineItems.length;
 for(int i = counter; i<numItems; i++){
 comPort.write(lineItems[i]);
 delay(500);
 comPort.write("6");
 }
 counter=numItems;
 }
}

Thursday, May 16, 2013

Gavia + Noble // Silly String Experiments

The next step of making our theft detection device a reality involved brainstorming what would be triggered upon the movement of ones personal belongings, in addition to the standard flashing lights and blaring alarm. Many ideas were thrown around – a bag of marbles bursting and flying everywhere (deemed too cumbersome), a smoke bomb detonating (too dangerous), text message being sent to your phone (too difficult and expensive considering the time-frame and student budget). Eventually, we decided to go with an aerosol can that sprays silly string, as it's compact and inexpensive while still delivering the spectacle that we wanted. Additionally, the user could potentially replace the silly string with mace, spray paint, or anything else in an aerosol can if they were looking for a more extreme theft deterrent.
We plan on attaching the wire that depresses the spray nozzle to a servo motor. When triggered by the motion sensor, it will rotate in alternating ten second and three second intervals for about 30 seconds, pulling the connecting wire and producing bursts of silly string. The photos below show the first tinkerings with the can and the wire. We used paper clips kept in place by strips of duct tape folded over to create a non-sticky channel through which they could easily pass, and we carved a divot in the top of the nozzle to keep the paper clip in place. Pulling the bottom of the wire with a small amount of force sprayed the string!




Unfortunately, the process of putting it together involved Gavia spraying a good amount of silly string by mistake (sometimes at Noble and other unsuspecting classmate – sorry guys), and the can is now empty. Our next steps will involve finding a more hi-fidelity way to attach the wire to the nozzle and run it along to the bottom of the can actually attach the wire to the servo motor.






Tuesday, May 14, 2013

MotionSensingCameraTriggeringProjectExtraordinaire

The final area of confusion for the success of our Motion-Sensing-Camera-Triggering Project was our ability to mimic an infrared remote control with an IR LED, our Arduino and Amy's Nikon D5100. The internet was helpful-ish (thanks to http://sebastian.setz.name/arduino/my-libraries/multi-camera-ir-control/ andhttp://www.bigmike.it/ircontrol/download.html). We ended up having the bits and pieces of code in our hands but not knowing what to do with them, or how to solve the errors on the Arduino program. Thankfully, and timely phone call with an electrical engineering uncle (Thank you, Andrew Hood!) helped add the appropriate "int"s and ";"s.

The following code was somewhat anticlimactic in that you can't see anything. The nature of the remote controls, and infrared lights, is that the sequence is fast and invisible to the naked eye. Unfortunately we still need to purchase an IR LED, so we weren't able to perform the ultimate test: can we actually take a picture with this bugger? In the end, we elongated the lengths of the light flashes, and plopped a regular old LED in our hardware, and were rewarded with a happy little flicker. More on wether we can actually take pictures with it later.

The Code:
  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 setup(){
}
void loop(){
  int _freq = 40;
   int _pin = 9;
  high(2000,_freq,_pin);
  wait(27830);
  high(390,_freq,_pin);
  wait(1580);
  high(410,_freq,_pin);
  wait(3580);
  high(400,_freq,_pin);
  delay(5000);
}
void wait(unsigned int time){
  }

Sunday, May 12, 2013

Pairing the Photoresistor to the Analog Sensor // karin & kristina's TOOTH MONSTER :)


For the purpose of dispensing floss by utilizing the actuator, this code triggers the actuator to move 180 degrees when the photoresistor is covered. 


#include <Servo.h>    
    Servo myservo;
    int pos = 5;
    int lightPin = 0;
    
    void setup() {
      // attach the pin 9 to the servo
      myservo.attach(9);
      Serial.begin(9600);
    }
    
    void loop() {
      // read the current voltage at lightPin (0) 
      int lightLevel = analogRead(lightPin); 
      Serial.println(lightLevel);
      
      if (lightLevel <= 500) {// turn to 180
      pos = 60;
      myservo.write(pos);
      }
     
      else {//turn to 0
      pos = 0;
      myservo.write(pos);
     }

Friday, May 10, 2013

Maddz & Candz: Arduino Practice Codes

We used to code from the Arduino Example files and modified it to produce both the brute force and for loop code. Both codes essentially makes the LED blink five times (counting 1, 2, 3, 4, 5), then wait for a while, and begin counting again.

Blink Code (Brute Force)
// Used Pin 13 for the LED
int led = 13;

// the setup routine runs once when you press reset:
void setup() {                
 // initialize the digital pin as an output.
 pinMode(led, OUTPUT);     
}


// the loop routine runs over and over again forever:
void loop() {
 digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
 delay(500);               // wait for a second
 digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
 delay(500);   // wait for a second
 
 digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
 delay(500);               // wait for a second
 digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
 delay(500);   // wait for a second
 
 digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
 delay(500);               // wait for a second
 digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
 delay(500);   // wait for a second
 
 digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
 delay(500);               // wait for a second
 digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
 delay(500);   // wait for a second
 
 digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
 delay(500);               // wait for a second
 digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
 delay(500);   // wait for a second
 
//waits 1 minute before blinking again
 delay (60000);
}


Blink Code (For Loop)

// Used Pin 13 as LED
int led = 13;

// the setup routine runs once when you press reset:
void setup() {                
 // initialize the digital pin as an output.
 pinMode(led, OUTPUT);     
}

// the loop routine runs over and over again forever:
void loop() {
 // LED blinks so long as count is less than 5.
 for (int count=0; count<5; count++) {
   digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
   delay(500);               // wait for a second
   digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
   delay(500);   // wait for a second
 }
// Waits for 1 minute before blinking again.
 delay(60000);
}



Button
Using the example from http://www.arduino.cc/en/Tutorial/Button, we were able to get the button system working. Here is the code we used from the website:


// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
 // initialize the LED pin as an output:
 pinMode(ledPin, OUTPUT);      
 // initialize the pushbutton pin as an input:
 pinMode(buttonPin, INPUT);     
}

void loop(){
 // read the state of the pushbutton value:
 buttonState = digitalRead(buttonPin);

 // check if the pushbutton is pressed.
 // if it is, the buttonState is HIGH:
 if (buttonState == HIGH) {     
   // turn LED on:    
   digitalWrite(ledPin, HIGH);  
 }
 else {
   // turn LED off:
   digitalWrite(ledPin, LOW);
 }
}


Below is a video showing the button at work:

video

Thursday, May 9, 2013

Noble + Gavia // Poster Showing Thief Detection Logic

Pseudocode and Ideation for Arduino Theft Detection Project

This is the poster that we made for class.  It outlines the logic behind our project.  Once the system is setup and armed, if somebody tries to steal the person's possessions, the system reacts to draw attention to itself and delay the thief.

Noble + Gavia // Practice Code and Replacement Parts

Since our parts haven't arrived in the mail yet, we made do with what the Sparkfun Inventor's Kit had.  We used the kit's piezo instead of a larger one, a potentiometer instead of a vibration sensor, a button instead of an infrared remote switch, and base LEDs instead of brighter ones.  I recently bought a larger servo from radioshack for the part where it shoots silly string, but this part of the project was done before then.

I coded the Arduino to arm itself when the button is pressed.  A LED comes on to show that it's armed and if the potentiometer's analog reading reaches a certain value, red LEDs flash on and the piezo makes a buzzing noise.  This code has the basic logic of our system.  The system can be armed or disarmed, and the sensor triggers a reaction once a certain value is detected.



Here's our code:


#define LED_ALARM 13   //Red LEDS on output pin 13
#define LED_ON 12   //Green LED on ouotput pin 12
#define BUTTON 2   //Button switch on input pin 2
#define SENSORPIN 0   //Potentiometer on analog input pin A0
#define BUZZER 11   //Piezo buzzer on output pin 11

int val = 0;   //It's value changes based on whether the button is pressed or not
int old_val = 0;   //Stores the old value of the button so it properly turn on or off
int state = 0;   //State of the button, is it on or off?
int sensorValue;   //Value of the potentiometer

void setup() {                
  pinMode(LED_ALARM, OUTPUT);
  pinMode(LED_ON, OUTPUT);
  pinMode(BUTTON, INPUT);
  pinMode(BUZZER, OUTPUT);
}

void loop() {
   val = digitalRead(BUTTON);   //Sets the value to LOW or HIGH based on the button being pressed or not

   if ((val == HIGH) && (old_val == LOW)){   //Changes the state of the button to on or off
     state = 1 - state;
     delay(10);
   }
   
   old_val = val;   //So we know that we're going from one button state to another when it's pressed
   
   if (state == 1) {   //If the button is pressed the green light comes on and the potentiometer starts to read
     digitalWrite(LED_ON, HIGH);
     sensorValue = analogRead(SENSORPIN);
   } else {
     digitalWrite(LED_ON, LOW);    //If the button isnt pressed then the light is off
   }
   if (sensorValue > 500) {   //If the potentiometer is a certain value, the alarm sounds and the red LEDs flash
      digitalWrite(LED_ALARM, HIGH);
      delay(250);
      digitalWrite(LED_ALARM, LOW);
      delay(250);
      
      buzz(BUZZER, 2500, 500);   //buzz the buzzer on pin 11 at 2500Hz for 500 milliseconds
      delay(1000);
    }
}

void buzz(int targetPin, long frequency, long length) {
  long delayValue = 1000000/frequency/2;     //calculate the delay value between transitions
  //// 1 second's worth of microseconds, divided by the frequency, then split in half since
  //// there are two phases to each cycle
  long numCycles = frequency * length/ 1000;    //calculate the number of cycles for proper timing
  //// multiply frequency, which is really cycles per second, by the number of seconds to 
  //// get the total number of cycles to produce
 for (long i=0; i < numCycles; i++){    //for the calculated length of time...
    digitalWrite(targetPin,HIGH);    //write the buzzer pin high to push out the diaphragm
    delayMicroseconds(delayValue);    //wait for the calculated delay value
    digitalWrite(targetPin,LOW);    //write the buzzer pin low to pull back the diaphragm
    delayMicroseconds(delayValue);    //wait again for the calculated delay value
  }
}