Browsing articles tagged with " light"
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);
}

}

May 7, 2011
admin

Calm Computing+IR Sensor Final = SleepWalker Alarm





















Code:

/*****************************************
* Liza Stark
* Physical Computing Final Project: Calm Computing
* May 3, 2011
*
* SleepWalker Alarm Clock
*
* This sketch uses a sharp IR sensor to detect motion
* when a person sits up in bed. The feedback comes in
* two stages: light and sound. When turned on, the dimLED
* acts as a nightlight to let the user know it is on. When the user sits up or moves within
* a range that is less than 60 cm, the dimLED goes off and the alarmLED turns on.
* If the user does not push the button within 15 seconds, the sound alarm goes off.
*
*
*
*
*
*****************************************/

int IRpin = 3; // analog pin for reading the IR sensor
int dimLED = 9; // Feedback LED to tell user it is on
int alarmLED = 10 ; // LED for first alarm
int speakerAlarm = 11; // Speaker alarm

int buttonPin = 7;
int buttonVal = 0;
int lastButtonVal = LOW;

int timer=0;
int lapse=15000;
int counter=0;

float volts;
float distance;
boolean alarm=false;

boolean restState = false;
boolean alarmOne = false; // This will test to see if
boolean alarmTwo = false;

boolean stayOff = false;

void setup() {

pinMode(dimLED, OUTPUT);
pinMode(alarmLED, OUTPUT);
pinMode(speakerAlarm, OUTPUT);
pinMode(buttonPin, INPUT);
Serial.begin(9600); // start the serial port
}
/**********************TIMER EXAMPLE************************/
//int timer=0;
//
//int lapse=2000;
//
//int counter=0;
//
//void setup(){
// Serial.begin(9600);
//}
//
//
//void loop(){
//
// if (millis()-timer>=lapse){
// counter++;
// timer=millis();
//
//
// }
//
// Serial.println(counter);

//}
/******************************************************************/

void loop() {

// Check IR and button values
volts = analogRead(IRpin)*0.0048828125; // value from sensor * (5/1024) - if running 3.3.volts then change 5 to 3.3
distance = 60*pow(volts, -1.0); // worked out from graph 65 = theretical distance / (1/Volts)S - luckylarry.co.uk
Serial.println(distance); // print the distance
delay(100);

buttonVal = digitalRead(buttonPin);

if(buttonVal){
Serial.println("pressed");
digitalWrite(dimLED,HIGH);
digitalWrite(alarmLED,LOW);
noTone(speakerAlarm);
digitalWrite(speakerAlarm,LOW);
alarm=false;

}
else{

if(distance < 60){ digitalWrite(alarmLED,HIGH); digitalWrite(speakerAlarm,LOW); digitalWrite(dimLED,LOW); digitalWrite(speakerAlarm,LOW); noTone(speakerAlarm); alarm=true; } } if(alarm){ if (millis()-timer>=lapse){
counter++;
timer=millis();
//Serial.println(counter);
Serial.println("speaker on");
digitalWrite(speakerAlarm,HIGH);
tone(speakerAlarm,10000);

}

}

}

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

Feb 28, 2011
admin
Comments Off

Stroke Sensor


How it works:
This stroke sensor uses conductive and resistive thread to complete the circuit and light up the LEDs (“threaded” in parallel).


Materials:

Conductive thread

Resistive thread

Conductive fabric

Fabric

Thread

Needle

Scissors

Pliers

Exacto knife

3V battery

LEDs

[vimeo http://www.vimeo.com/20455091 w=398&h=294]

Feb 14, 2011
admin
Comments Off

Valentine’s Pressure

This circuit has one pressure sensor to activate the right and middle heart and a “switch” to complete the circuit and turn on the last heart.








Materials:
felt
bristol paper
conductive thread
regular thread
conductive fabric
Velostat (resistive fabric)
5050 LED
tape
glue (Sobo Premium Craft and Fabric Glue)
scissors
needle
exacto