Weather Wardrobe

Made by Diana Sun

A decorative hanging piece on the closet that shows users what they should wear based on the day's weather forecast.

Created: December 20th, 2015


Weather Wardrobe is a something users can put in their bedroom to help them visually see what they should wear each day. The wooden box sits on the bed side table, and the distance sensor on the bottom will know when the user's hand reaches over to turn off their morning alarm. This then activates the lasers and tells the system to map the day's weather forecast. The lasers move in a horizontal motion to point a red beam of light at the point on the scale that matches the weather API data. The top laser goes from "bikini weather" to "jacket weather", while the bottom laser goes from "100% rain" (umbrella) to "sunshine". This tells the user if they should wear layers or bring an umbrella for the day, without having to check their phone or look out the window to guess the weather.

import processing.serial.*;
import org.firmata.*;
import cc.arduino.*;

//create json object, which will store the json file
JSONObject json;

//this is the URL endpoint that we want to call to retrieve the JSON
String rainURL = "";
Arduino myarduino;
int start = 0;
int maxpercent = 1;

void setup() {
  size(200, 200);
  myarduino = new Arduino(this, Arduino.list()[0], 57600);
  myarduino.pinMode(5, Arduino.OUTPUT);
  myarduino.pinMode(6, Arduino.OUTPUT);
  myarduino.pinMode(9, Arduino.SERVO);                   //servo temperature
  myarduino.pinMode(10, Arduino.SERVO);                  //servo percip
  myarduino.pinMode(0, Arduino.INPUT);                   //distance sensor

void draw() {
  background(210, 225, 250); 
  float i = myarduino.analogRead(0);
  float val = (6762/(i-9))-4;
  if (val >= 6 && val <= 13 && start==0) {
     start = 1; 

void loadData() {
  //get the JSON file
  json = loadJSONObject(rainURL);
  println("we got JSON!");
  //get the JSON object named "results", which contains the array we want!
  JSONObject results = json.getJSONObject("results");
  //get the array titled "collection1"
  JSONArray array = results.getJSONArray("collection1");
  println("length of array: " + array.size());
  int totaltemp = 0;
  int avgtemp = 0;
  int start = 0;

  if(array.size() > 0)
    for(int i = 0; i < array.size(); i++)                       //go through each section and find the "amnt"
      JSONObject currentindex = array.getJSONObject(i);         //get the first dataGroup in the "collection1" array
      String percentage = currentindex.getString("percip");
      percentage = percentage.replaceAll("%","");
      int percent = parseInt(percentage);                       //percentage of rain
      println("percip percentage " + i + ": " + percent);
      if (percent >= maxpercent) {
         maxpercent = percent;
         println("maxpercent is" + maxpercent);    
      int temperature = currentindex.getInt("temp");            //temperature
      println("temperature is" + temperature);
      totaltemp = totaltemp + temperature;
    myarduino.digitalWrite(5, Arduino.HIGH);                    //turn on light regardless
    myarduino.digitalWrite(6, Arduino.HIGH);                    //turn on light regardless
    avgtemp = (totaltemp)/ array.size();
    println("avg temp is " + avgtemp);
    int mappedTemp = (int)map(avgtemp, 30, 100, 70, 110);  
    println("mappedTemp is " + mappedTemp);
    myarduino.analogWrite(9, mappedTemp);
    int mappedPercip = (int)map(maxpercent, 0, 100, 70, 110);
    println("mappedPercip is " + mappedPercip);
    myarduino.analogWrite(10, mappedPercip);
Click to Expand
Share this Project


48-739 Making Things Interactive

· 0 members

Making Things Interactive (MTI) is a studio course based on physical prototyping and computing. You will develop novel sensing, interaction and display techniques through projects and short assignm...more


A decorative hanging piece on the closet that shows users what they should wear based on the day's weather forecast.