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

Noble Woods & Gavia Angell // Physical IxD Final


Detect
Noble Woods and Gavia Angell
Physical Interaction Design Final Project, Spring 2013

Description:

Our Arduino project has turned out very close to our initial ideas and designs from earlier this quarter.  We created it to deal with possible theft that might occur when a person exits the room, leaving their possessions behind.  To prevent theft, a user can clamp the device to their possessions and arm it via remote control.  If anyone moves or attempts to steal their possessions, red leds flash and an alarm sounds.  If positioned correctly, the device will spray the thief with silly string, discouraging them and giving them a good scare.

Posters: 



References:

-Various Arduino forum posts
-Next door neighbor

Code:

// Noble Woods, Physical Interaction Design, June 2013
// Arduino Thief Detector Project Code

#include <Servo.h>
#include <IRremote.h>

#define LED_ALARM 10    // Red Alarm LEDS attached to output pin 10
#define LED_ON 12    // Green On LED ottached to output pin 12
#define RECV_PIN 2    // IR sensor attached to input pin 2
#define SENSORPIN A0    // Vibration sensor attached to analog input pin A0
#define BUZZER 13    // Piezo buzzer ottached to output pin 13
#define SERVOPIN 9    // Servo attached to output pin 8

Servo myServo;    // Connects to the servo output pin
unsigned long servo_timer_start;  // Starts the timer for the server when called
boolean stoploop = true;    // Becomes false after the servo as ran once

IRrecv irrecv(RECV_PIN);    // Create an instance of "irrecv"
decode_results results;

boolean state = false;    // State of the button, if the remote's power button is pressed, it changes the state to true and turns everything on

unsigned long alarm_timer_start;    // Starts the timer for the blinking alarm lights and buzzer
long old_timer = 0;    // By setting it equal to the alarm timer, it lets the LEDs blink every given number of miliseconds
int ledstate = LOW;    // Makes it convenient to turn the alarm leds on and off every number of seconds
int buzzerstate = LOW;    // Same as ledstate except for the buzzer

int sensorValue;   // The value recorded by the vibration sensor
boolean thiefStealing = false;    // Is set to true when the sensorValue detects a vibration large enough to associate with stealing


void setup() {  
  pinMode(LED_ALARM, OUTPUT);
  pinMode(LED_ON, OUTPUT);
  pinMode(SENSORPIN, INPUT);
  pinMode(BUZZER, OUTPUT);
  myServo.attach(SERVOPIN);
  irrecv.enableIRIn();    // Start the IR receiver
  Serial.begin(9600);
}


void loop() {
   if (irrecv.decode(&results)) {    // Reads the infrared coming into the infrared sensor
     if (results.value == 3017984774 || results.value == 50153655 || results.value == 439282747) {    // If the infrared coming in matches the power button on the remote, it changes state's current value
       if (!state) {
         state = true; 
       } else {
         state = false;
       }
     }
     irrecv.resume();
     //Serial.println(results.value);
   }
   
   if (!state) {
     digitalWrite(LED_ON, LOW);    // Turns the light off
     digitalWrite(LED_ALARM, LOW);    // Turns the light off
     analogWrite(BUZZER, LOW);
     thiefStealing = false;    // Resets the data that identifies if the object is being stolen
     servo_timer_start = 0;    // Resets the servo timer
     alarm_timer_start = 0;    // Resets the alarm timer
     old_timer = 0;
     stoploop = true;
     
   } else if (state) {    // If the remote's power button is pressed, turns the state to true
     digitalWrite(LED_ON, HIGH);    // Turns the green led on
     
     sensorValue = analogRead(SENSORPIN);    // Reads the along data from the vibration sensor
     Serial.println(sensorValue);
     
     if (sensorValue >= 983) {    // If the vibration sensor detects a large movement, thiefstealing is set to true
       thiefStealing = true;
     }
     if (thiefStealing) {
       if (stoploop) {    // Checks to see whether the servo should keep running
        if(!servo_timer_start) {
           servo_timer_start = millis();    // Sets the time at the current time
        }
        myServo.write(0);    // Moves the servo to an intial starting point
        //myServo.write(360);
        if ((millis() - servo_timer_start) >= 3000) {    // If the current time minus the recorded time is greater than the interval
          myServo.write(360);    // Move the servo 180 degrees
          stoploop = false;    // Prevents the servo from running more than once until the system is armed once again
        }
       }      
       
       alarm_timer_start = millis();    // Starts the alarm timer
       if ((alarm_timer_start - old_timer) >= 300) {    // Every 3 seconds blinks the LED and buzzer
        old_timer = alarm_timer_start;
        if (ledstate == LOW && buzzerstate == LOW) {          
          ledstate = HIGH;
          buzzerstate = 1000;
        } else {
          ledstate = LOW;
          buzzerstate = LOW;     
        }
        digitalWrite(LED_ALARM, ledstate);
        analogWrite(BUZZER, buzzerstate);
      }
    }
   }

}

No comments:

Post a Comment