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 7, 2016

Molight by Logan and Natalie

After a quarter of work, Logan and I worked to make Molight, a lamp with four lights that divides any room into four quadrants and uses motion sensors. The premise behind our project was to make a light that forced people to get up to move after staying put for a long time. The light detects which quadrant you are in, and stays on in that quadrant for an hour if you don't move. It then switches each light to be on, while the other lights are off, in a circular motion quickly, signaling the user to move to a new section. Once the user has moved to a new section of the room, the light in that quadrant turns on and the others turn off. We hope you enjoy our project! 
This is a photo of the lamp from the bottom- here, you can see the PIR sensors separated by the cross-shaped obstacle in the middle, and the four arms that separate the four lights. While four lights will never actually be on in our project at the same time, the evenness allowed us to take a picture that shows how nicely the acrylic glows against the lights. 
This is a photo of the lamp from the side, where you can see how metal wire holds the arms of the lights, and then wire holds up the entire piece, rather than relying on the weight held by the electrical cord. 

Molight from Natalie Lew on Vimeo.

Our Code: 
//WHICH PINS INTERFACE WITH THE RELAY AND THE LIGHTBULBS
int ledPin1 = 12;
int ledPin2 = 11;
int ledPin3 =10;
int ledPin4 = 9;

//WHICH PINS INTERFACE WITH THE PIR SENSORS
int inputPin1 = 7;
int inputPin2 = 6;
int inputPin3 = 5;
int inputPin4 = 4;

//THE STARTING STATE OF THE PIR SENSORS (NO MOTION)
int pirState1 = LOW;
int pirState2 = LOW;
int pirState3 = LOW;
int pirState4 = LOW;

//MORE STUFFFFDFDFDFD
int val1 = 0;
int val2 = 0;
int val3 = 0;
int val4 = 0;

//PULSES FOR SINGLE ON
boolean pulse1;
boolean pulse2;
boolean pulse3;
boolean pulse4;

boolean zoneOneOccupied;
boolean zoneTwoOccupied;
boolean zoneThreeOccupied;
boolean zoneFourOccupied;

int timeAllowed = 10000; // ten seconds in millis()
unsigned long timer;
boolean timeExpired;
unsigned long startDelayTimer;


void setup() {
 Serial.begin(9600);

 //LIGHBULB OUTPUTS
 pinMode(ledPin1, OUTPUT);
 pinMode(ledPin2, OUTPUT);
 pinMode(ledPin3, OUTPUT);
 pinMode(ledPin4, OUTPUT);

 //SENSOR INTPUTS
 pinMode(inputPin1, INPUT);
 pinMode(inputPin2, INPUT);
 pinMode(inputPin3, INPUT);
 pinMode(inputPin4, INPUT);

 boolean zoneOneOccupied = false;
 boolean zoneTwoOccupied = false;
 boolean zoneThreeOccupied = false;
 boolean zoneFourOccupied = false;

}

void loop() {
 Serial.print("millis is ");
 Serial.println(millis());
 Serial.print("timer is ");
 Serial.println(timer);




 ///////////////////////////////
 //CHECKING ALL OF THE SENSORS//
 ///////////////////////////////

 //ZONE ONE ACTIVITY
 val1 = digitalRead(inputPin1);
 if (val1 == HIGH) {
   if (pirState1 == LOW) {
     pirState1 = HIGH;
     pulse1 = true;
   }
 } else {
   if (pirState1 == HIGH) {
     pirState1 = LOW;
   }
 }
 //pirState1 = digitalRead(inputPin1);

 //ZONE TWO ACTIVITY
 val2 = digitalRead(inputPin2);
 if (val2 == HIGH) {
   if (pirState2 == LOW) {
     pirState2 = HIGH;
     pulse2 = true;
   }
 } else {
   if (pirState2 == HIGH) {
     pirState2 = LOW;
   }
 }

 //ZONE THREE ACTIVITY
 val3 = digitalRead(inputPin3);
 if (val3 == HIGH) {
   if (pirState3 == LOW) {
     pirState3 = HIGH;
     pulse3 = true; 
   }
 } else {
   if (pirState3 == HIGH) {
     pirState3 = LOW;
   }
 }

 //ZONE FOUR ACTIVITY
 val4 = digitalRead(inputPin4);
 if (val4 == HIGH) {
   if (pirState4 == LOW) {
     pirState4 = HIGH;
     pulse4 = true;
   }
 } else {
   if (pirState4 == HIGH) {
     pirState4 = LOW;
   }
 }

 ///////////////////////////////////////
 //ACTING ON THE OUTPUT OF THE SENSORS//
 ///////////////////////////////////////
 //ZONE ONE
 if(pulse1) {
   pulse1 = false;
   Serial.println("one");
   if(!zoneOneOccupied) {
     timer = millis();
     timeExpired = false;
     digitalWrite(ledPin1, HIGH);
     zoneOneOccupied = true;
     zoneTwoOccupied = false;
     zoneThreeOccupied = false;
     zoneFourOccupied = false;

     digitalWrite(ledPin2, LOW);
     digitalWrite(ledPin3, LOW);
     digitalWrite(ledPin4, LOW);
     //delay(timeToDelay);
   }
 }
 if(!zoneOneOccupied && !timeExpired) {
   digitalWrite(ledPin1, LOW);
 }
 //ZONE TWO
 if(pulse2) {
   pulse2 = false;
   Serial.println("      two");
   if(!zoneTwoOccupied) {
     timer = millis();
     timeExpired = false;
     digitalWrite(ledPin2, HIGH);
     zoneTwoOccupied = true;
     zoneOneOccupied = false;
     zoneThreeOccupied = false;
     zoneFourOccupied = false;

     digitalWrite(ledPin1, LOW);
     digitalWrite(ledPin3, LOW);
     digitalWrite(ledPin4, LOW);
     //delay(timeToDelay);

   }
 }
 if(!zoneTwoOccupied && !timeExpired) {
   digitalWrite(ledPin2, LOW);
 }  
 //ZONE THREE
 if(pulse3) {
   pulse3 = false;
   Serial.println("            three");
   if(!zoneThreeOccupied) {
     timer = millis();
     timeExpired = false;
     digitalWrite(ledPin3, HIGH);
     zoneThreeOccupied = true;
     zoneOneOccupied = false;
     zoneTwoOccupied = false;
     zoneFourOccupied = false;

     digitalWrite(ledPin1, LOW);
     digitalWrite(ledPin2, LOW);
     digitalWrite(ledPin4, LOW);
     //delay(timeToDelay);

   }
 }
 if(!zoneThreeOccupied && !timeExpired) {
   digitalWrite(ledPin3, LOW);
 }  
 //ZONE FOUR
 if(pulse4) {
   pulse4 = false;
   Serial.println("                    four");
   if(!zoneFourOccupied) {      
     timeExpired = false;
     timer = millis();
     digitalWrite(ledPin4, HIGH);
     zoneFourOccupied = true;
     zoneOneOccupied = false;
     zoneTwoOccupied = false;
     zoneThreeOccupied = false;

     digitalWrite(ledPin1, LOW);
     digitalWrite(ledPin2, LOW);
     digitalWrite(ledPin3, LOW);
     //delay(timeToDelay);

   }
 }
 if(!zoneFourOccupied && !timeExpired) {
   digitalWrite(ledPin4, LOW);
 }

 ///////////////////////////////////////////////
 //WHEN PEOPLE SPEND TOO MUCH TIME IN ONE ZONE//
 ///////////////////////////////////////////////
 if (millis() - timer > timeAllowed && timer > 0) {
   if(!timeExpired) {
     startDelayTimer = millis();
   }
   timeExpired = true;
   Serial.println(startDelayTimer);
 }

 if(timeExpired) {
   Serial.println("time expired");
   if(startDelayTimer < 1) {
     digitalWrite(ledPin1, LOW);
     digitalWrite(ledPin2, LOW);
     digitalWrite(ledPin3, LOW);
     digitalWrite(ledPin4, LOW);
   }
   if( millis() - startDelayTimer < 500) {
     digitalWrite(ledPin1, HIGH);
   } else if(millis() - startDelayTimer < 1000) {
     digitalWrite(ledPin1, LOW);
     digitalWrite(ledPin2, HIGH);
   } else if(millis() - startDelayTimer < 1500) {
     digitalWrite(ledPin2, LOW);
     digitalWrite(ledPin3, HIGH);
   } else if(millis() - startDelayTimer < 2000) {
     digitalWrite(ledPin3, LOW);
     digitalWrite(ledPin4, HIGH);
   } else {
     digitalWrite(ledPin4, LOW);
     startDelayTimer = millis();
   }
 }  

}

No comments:

Post a Comment