Browsing articles tagged with " time"
May 7, 2011
admin

Light+Time Final: PhysComp Room Countdown Clock


















Code:

/*****************************************
* Liza Stark
* Physical Computing Final Project: Light+Time
* May 3, 2011
*
* This sketch uses the Macetech Chronodot and I2C protocol
* to program a cleanup countdown clock for the p comp room.
*
* Code for the I2C communication with the Chronodot was
* adapted from code written by Maurice Ribble. Documentation
* of it can be found here: http://www.glacialwanderer.com/hobbyrobotics/?p=12
*
*
*
*
*
*****************************************/

#include "Wire.h"
#define DS1307_I2C_ADDRESS 0x68

int cleanUpLED = 8; //Set LED action for first alarm
int lastCallLED = 10; //Set LED action for second alarm
int getOutLED = 11; //Set LED action for third alarm

// Convert normal decimal numbers to binary coded decimal
byte decToBcd(byte val)
{
return ( (val/10*16) + (val%10) );
}

// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
return ( (val/16*10) + (val%16) );
}

void setDateDs1307(byte second, // 0-59
byte minute, // 0-59
byte hour, // 1-23
byte dayOfWeek, // 1-7
byte dayOfMonth, // 1-28/29/30/31
byte month, // 1-12
byte year) // 0-99
{
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0);
Wire.send(decToBcd(second)); // 0 to bit 7 starts the clock
Wire.send(decToBcd(minute));
Wire.send(decToBcd(hour));
Wire.send(decToBcd(dayOfWeek));
Wire.send(decToBcd(dayOfMonth));
Wire.send(decToBcd(month));
Wire.send(decToBcd(year));
Wire.endTransmission();
}

// Gets the date and time from the ds1307
void getDateDs1307(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
// Reset the register pointer
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0);
Wire.endTransmission();

Wire.requestFrom(DS1307_I2C_ADDRESS, 7);

*second = bcdToDec(Wire.receive() & 0x7f);
*minute = bcdToDec(Wire.receive());
*hour = bcdToDec(Wire.receive() & 0x3f);
*dayOfWeek = bcdToDec(Wire.receive());
*dayOfMonth = bcdToDec(Wire.receive());
*month = bcdToDec(Wire.receive());
*year = bcdToDec(Wire.receive());
}

void setup()
{
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
Wire.begin();
Serial.begin(9600);

// Change values to set clock
second = 30;
minute = 15;
hour = 2;
dayOfWeek = 1;
dayOfMonth = 25;
month = 4;
year = 11;
setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);

pinMode (cleanUpLED,OUTPUT);
pinMode (lastCallLED,OUTPUT);
pinMode (getOutLED,OUTPUT);

}

void loop()
{
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;

getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
Serial.print(hour, DEC);
Serial.print(":");
Serial.print(minute, DEC);
Serial.print(":");
Serial.print(second, DEC);
Serial.print(" ");
Serial.print(month, DEC);
Serial.print("/");
Serial.print(dayOfMonth, DEC);
Serial.print("/");
Serial.print(year, DEC);
Serial.print(" Day_of_week:");
Serial.println(dayOfWeek, DEC);

delay(1000);

//Set tests for each day of the week

//////////////*********************************Initial Test***********************************//////////////////////
// Starts at 2:15:30 on Day 1

//2:15:40 am = Clean Up!
if((dayOfWeek == 4 ||dayOfWeek == 3 ||dayOfWeek == 2 ||dayOfWeek == 1) && hour == 2 && minute == 15 && second == 40)
{
Serial.println("Clean up!");
digitalWrite(cleanUpLED, HIGH);
digitalWrite(lastCallLED, LOW);
digitalWrite(getOutLED, LOW);

delay(4000);

digitalWrite(cleanUpLED, LOW);
}

//2:15:50 am = Last Call_This is not a pub
if((dayOfWeek == 4 ||dayOfWeek == 3 ||dayOfWeek == 2 ||dayOfWeek == 1) && hour == 2 && minute == 15 && second == 50)
{
Serial.println("Last Call - this is not a pub");
digitalWrite(cleanUpLED, LOW);
digitalWrite(lastCallLED, HIGH);
digitalWrite(getOutLED, LOW);

delay(4000);

digitalWrite(lastCallLED, LOW);
}

//2:16:00 am = Get Out
if((dayOfWeek == 4 ||dayOfWeek == 3 ||dayOfWeek == 2 ||dayOfWeek == 1) && hour == 2 && minute == 16 && second == 00)
{
Serial.println("Get out.");
digitalWrite(cleanUpLED, LOW);
digitalWrite(lastCallLED, LOW);
digitalWrite(getOutLED, HIGH);

delay(4000);

digitalWrite(getOutLED, LOW);
}

//////////////*********************************Test Monday - Thursday***********************************//////////////////////

//12:50 am = Clean Up!
if((dayOfWeek == 4 ||dayOfWeek == 3 ||dayOfWeek == 2 ||dayOfWeek == 1) && hour == 0 && minute == 50 && second == 0)
{
Serial.println("Clean up!");
digitalWrite(cleanUpLED, HIGH);
digitalWrite(lastCallLED, LOW);
digitalWrite(getOutLED, LOW);

delay(4000);

digitalWrite(cleanUpLED, LOW);
}

//1:15 am = Last Call_This is not a pub
if((dayOfWeek == 4 ||dayOfWeek == 3 ||dayOfWeek == 2 ||dayOfWeek == 1) && hour == 1 && minute == 15 && second == 0)
{
Serial.println("Last Call - this is not a pub");
digitalWrite(cleanUpLED, LOW);
digitalWrite(lastCallLED, HIGH);
digitalWrite(getOutLED, LOW);

delay(4000);

digitalWrite(lastCallLED, LOW);
}

//1:30 am = Get Out
if((dayOfWeek == 4 ||dayOfWeek == 3 ||dayOfWeek == 2 ||dayOfWeek == 1) && hour == 1 && minute == 30 && second == 0)
{
Serial.println("Get out.");
digitalWrite(cleanUpLED, LOW);
digitalWrite(lastCallLED, LOW);
digitalWrite(getOutLED, HIGH);

delay(4000);

digitalWrite(getOutLED, LOW);

}

//////////////*********************************Test Friday and Sunday***********************************//////////////////////

//10:50 pm = Clean Up!
if((dayOfWeek == 5 || dayOfWeek == 7) && hour == 23 && minute == 50 && second == 0)
{
Serial.println("Clean up!");
digitalWrite(cleanUpLED, HIGH);
digitalWrite(lastCallLED, LOW);
digitalWrite(getOutLED, LOW);

delay(4000);

digitalWrite(cleanUpLED, LOW);
}

//11:15 pm = Last Call_This is not a pub
if((dayOfWeek == 5 || dayOfWeek == 7) && hour == 24 && minute == 15 && second == 0)
{
Serial.println("Last Call - this is not a pub");
digitalWrite(cleanUpLED, LOW);
digitalWrite(lastCallLED, HIGH);
digitalWrite(getOutLED, LOW);

delay(4000);

digitalWrite(lastCallLED, LOW);
}

//11:30 pm = Get Out
if((dayOfWeek == 5 || dayOfWeek == 7) && hour == 24 && minute == 30 && second == 0)
{
Serial.println("Get out.");
digitalWrite(cleanUpLED, LOW);
digitalWrite(lastCallLED, LOW);
digitalWrite(getOutLED, HIGH);

delay(4000);

digitalWrite(getOutLED, LOW);
}

//////////////*********************************Test Saturday***********************************//////////////////////

//6:50 pm = Clean Up!
if(dayOfWeek == 6 && hour == 18 && minute == 50 && second == 0)
{
Serial.println("Clean up!");
digitalWrite(cleanUpLED, HIGH);
digitalWrite(lastCallLED, LOW);
digitalWrite(getOutLED, LOW);

delay(4000);

digitalWrite(cleanUpLED, LOW);
}

//7:15 pm = Last Call_This is not a pub
if(dayOfWeek == 6 && hour == 19 && minute == 15 && second == 0)
{
Serial.println("Last Call - this is not a pub");
digitalWrite(cleanUpLED, LOW);
digitalWrite(lastCallLED, HIGH);
digitalWrite(getOutLED, LOW);

delay(4000);

digitalWrite(lastCallLED, LOW);
}

//7:30 pm = Get Out
if(dayOfWeek == 6 && hour == 19 && minute == 30 && second == 0)
{
Serial.println("Get out.");
digitalWrite(cleanUpLED, LOW);
digitalWrite(lastCallLED, LOW);
digitalWrite(getOutLED, HIGH);

delay(4000);

digitalWrite(getOutLED, LOW);
}

}

Apr 13, 2011
admin

PhysComp Final Project Concept 1

Light+Time

For my light and time final project, I am stepping away from the modules for a more topical subject more in the line of calm computing: a countdown clock for the p comp room. After a program-wide email stressing our timeliness in cleaning up (I withhold judgment on the validity of sending an email in this particular situation) AND the general state of the p comp room during finals/thesis, I propose a countdown clock that will be programmed in accordance with building closing hours. There are four stages (names are subject to change): get ready, clean up, no really, clean up, and get out.














Mar 9, 2011
admin
Comments Off

LIGHTandTIME



Prototype 1

This is documentation for the first prototype of the light and time in Physical Computing 1. For assignment, we were charged to construct a prototype using only LEDs and one push button (if any), with a focus on calm computing.

My object is a look and feel prototype that conveys the idea of having a modular clock made of cubes that you can rearrange to keep time of a certain task. The light fades at a higher rate for those that need more immediate attention, and more slowly for those that do not.

Critique & Feedback

The class liked the look and feel of the cubes, and they were responsive to the modular concept. There was concern, however, that as a set of objects acting as an ambient task manager would strain rather than relieve mental stress since s/he would have to remember what each cube was and also be tasked with programming the cube when the task changed. While this issue could be negotiated in numerous ways, I think I am going to drop the concept of task manager in favor of exploring how objects relate and react to each other over time. Another suggestion aside from modes of interaction was the idea to manipulate the shape and size of the objects.

Further Iterations

For the next series of prototypes, I want to play with ideas of interactions among multiples and the resulting emergent behavior. I will test size, shape, hierarchy, and color interaction. Mission One: triangles are fun.

Process