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

Nick and Mason Final































Ever leave the house in shorts and a T-shirt only to get soaked by a torrential downpour in the afternoon? Wouldn't it be nice if you knew to bring gear for a rainy day? Weathermate solves this problem by letting you know what you need.

Weathermate uses a online resource called If This Than That which is able to take the daily weather report and send it to a drop box folder. This file is then moved and renamed by Hazel so that Processing can read the file and send the necessary instructions to the Arduino, which are the the brains of Weathermate


The Arduino Code:

#include "Servo.h"

Servo motor;
Servo motor2;
Servo motor3;

int x;
int r;


void setup() {
  //Set up for Sensor
  pinMode(3, INPUT);


  // Set up for Sun
  pinMode(6, OUTPUT);
  motor.attach(6);
  pinMode(7, OUTPUT);

  //Set up for Rain
  pinMode(9, OUTPUT);
  motor2.attach(9);
  motor2.write(90);
  pinMode(8, OUTPUT);

  //Set up for Snow
  pinMode(11, OUTPUT);
  motor3.attach(11);
  pinMode(12, OUTPUT);

  Serial.begin(9600);

}

void loop() {

  //this was for testing purposes so that we could see where the what instruction the Arduino had.
  Serial.println(r);

  //Senses if a person is there
  if(digitalRead(3) == HIGH){

    //If it is going to rain
    if (r == 1) {
      
      Serial.println("Rain");

      digitalWrite(8, HIGH);

      motor2.write(180);
      delay(2000);

      Serial.println("180");
    
      motor2.write(90);
      Serial.println("90");
      delay(5000);

      motor2.write(0);
      delay(600);
      Serial.println("0");

      motor2.write(90);
      Serial.println("90");

      delay(5000);
      digitalWrite(8, LOW);
      
      Serial.println("Rain");
    }



    //if it is going to be sunny 
    if (r == 2) {

      //we only had one srvo mottor so  the code for it was simple for this one.
      motor.write(0);
      digitalWrite(7, HIGH);
      Serial.println("Sunnnnnnnnn");
      delay(5000);
      motor.write(180);
      digitalWrite(7, LOW);  

    }




    //If it was going to snow / the weather was going to be cold
    if (r == 3) {
      Serial.println("Rain");

      digitalWrite(12, HIGH);

      motor3.write(180);
      delay(2000);

      Serial.println("180");
    
      motor3.write(90);
      Serial.println("90");
      delay(5000);

      motor3.write(0);
      delay(600);
      Serial.println("0");

      motor3.write(90);
      Serial.println("90");

      delay(5000);
      digitalWrite(12, LOW);
     


    }
  }






  
// This was the basic function we used to take the incoming information and 
// translate it to a variable that Arduino could use. 

  if (Serial.available()) {
    x = Serial.read();
    x  = x-48 ;
    Serial.println(x);


    if (x == 1 || x == 2 || x==3 || x==4) {
      r= x;
    }


  }
}




The Processing code

String[] lines;
String[] today;
String[] possible;
String[] numb;


String str1 = "CCCP";
String str2 = "CCCP";
String str3 = "CCCP";
String str4 = "CCCP";
String str5 = "CCCP";


int x = 2;

///
import processing.serial.*;
Serial comPort;


///
void setup() {
  
//For processing to be able to communicate with the Arduino we needed to initialize a connection 
//The 6 that you see there is telling the computer which port(usb) to look at.

  comPort = new Serial(this, Serial.list()[6], 9600);
}

void draw() {
  
  
// text file for the weather of the day
  today = loadStrings("Weather.txt");
  
  // the instructions that will be sent
  numb = loadStrings("2.txt");
  
  // the possible out comes that the forecast will be compared to
  possible = loadStrings("possible.txt");


  str1 = today[0];
  str2 = possible[0];
  str3 = possible[1];
  str4 = possible[2];
  str5 = possible[3];

//for testing
  println(str1);
  println(str2);
  println(str3);
  println(str4);
  println(str5);


//looks for rain
  if (str1.equals(str2) == true  ) {
    println("Rainnnnnnn");
    comPort.write(numb[0]);

    delay(500);
    comPort.write("6");
    delay(6000);

  }
  
  //looks for sun
    if (str1.equals(str3) == true ) {
    println("Sunnnnnnnn");
    comPort.write(numb[1]);

    delay(500);
    comPort.write("6");
    delay(6000);
  }
  
  
  // Looks for snow
    if (str1.equals(str4) == true) {
    println("Snowwwwwwww");
    comPort.write(numb[3]);

    delay(500);
    comPort.write("6");
    delay(6000);
  }
}

















No comments:

Post a Comment