SAMMANFATTNING

Den här rapporten beskriver hur ljus, musik och tid kan användas för att motverka stress och hjälpa dig att vakna upp bättre, eftersom många människor har problem med det. Kärnidéen kommer ifrån forskning om melatoninkontroll där man använder ljus, stressreduktion där man använder musik och sömnförbättring där man använder två alarm (genom att använda tid). Baserat på gjord forskning byggdes en väckarklocka. Den är gjord så att användaren ska kunna ställa in väckarklockan så att det passar honom/henne. Under utställningen gavs bra feedback. Många gillade konceptet och tyckte att man även kunde lägga till kopplingar till andra maskiner i hemmet och att man skulle kunna kontrollera REM sömnen. Några tyckte systemet var för kontrollerande och att det skulle passa bättre inom hälsovård. Framtida utveckling skulle kunna innehålla en uppkoppling mot TV, Iphone eller dator samt fungera för flera användare.

Nyckelord: Väckarklocka, melatonin, stress, sömnförbättring, musik och sömn.

ABSTRACT

This report describes how light, music and time can be used to help you sleep and to wake up better since many people suffer from stress and sleeping disorders. The core idea of the project rose from research around melatonin control using light, stress reduction using music and the use of two alarms to train the body (using time). An alarm clock was built based on the suggested research. It is made in a way that it’s always controllable in any mode of preferred usage. During the exhibition most people liked the concept and other features could be added in the future and to control REM sleep. Some people thought it was too controlling and said it could fit better in health care. Future work could connect the device to the TV, Iphone or computer and to consider multiple users.

Keywords: Alarm clock, melatonin, stress, sleep deprivation, music and sleep.

Our three devices on a table for creative working late at night

fredag 18 december 2009

Source code for light control device

#include "TimerOne.h" // Avaiable from http://www.arduino.cc/playground/Code/Timer1

volatile int i=0; // Variable to use as a counter
volatile boolean zero_cross=0; // Boolean to store a "switch" to tell us if we have crossed zero
int AC_pin = 10; // Output to Opto Triac
int Dimmer_pin = 0; // Pot for testing the dimming
int LED = 3; // LED for testing
int dim = 0; // Dimming level (0-128) 0 = on, 128 = 0ff
int freqStep = 78; // Set the delay for the frequency of power (65 for 60Hz, 78 for 50Hz) per step (using 128 steps)
// freqStep may need some adjustment depending on your power the formula
// you need to us is (500000/AC_freq)/NumSteps = freqStep
// You could also write a seperate function to determine the freq

#include

NewSoftSerial mySerial(5,6);
int val;
int val2;
int value;
int dm=0;
int bt=0;
int of=0;
int onn=0;
int dmof=0;
int bton=0;
byte some=0;
void setup()
{
onn=1;
mySerial.begin(19200);
Serial.println("Beginning ... ");
//pinMode(pin6,INPUT);
pinMode(AC_pin, OUTPUT); // Set the Triac pin as output
pinMode(LED, OUTPUT); // Set the LED pin as output
attachInterrupt(0, zero_cross_detect, CHANGE); // Attach an Interupt to Pin 2 (interupt 0) for Zero Cross Detection , this is where is did some modification adn used change instead of falling.
Timer1.initialize(freqStep); // Initialize TimerOne library for the freq we need
Timer1.attachInterrupt(dim_check, freqStep); // Use the TimerOne Library to attach an interrupt

}
void zero_cross_detect() { // function to be fired at the zero crossing
zero_cross = 1; // set the boolean to true to tell our dimming function that a zero cross has occured
}
void dim_check() // Function will fire the triac at the proper time
{
digitalWrite(AC_pin, LOW); // Turn off the Triac gate (Triac will not turn off until next zero cross)
if(zero_cross == 1) // First check to make sure the zero-cross has happened else do nothing
{
if(i>=dim) // Check and see if i has accumilated to the dimming value we want
{

digitalWrite(AC_pin, HIGH);// Fire the Triac mid-phase

i = 0; // Reset the accumilator
zero_cross = 0; // Reset the zero_cross so it may be turned on again at the next zero_cross_detect
} else {
i++; // If the dimming value has not been reached, incriment our counter
} // End dim check
} // End zero_cross check
}

void loop()
{
recieve();

}




void recieve()
{

if (mySerial.available())
{
val2=(int)mySerial.read();
val2=val2-48;
if(val2==1)
{
bton=0;
dimmer();
}
else if(val2==2)
{

bton=0;
brigth();

}
else if(val2==3)
{

//sendAck();
bton=0;
on();
}
else if(val2==4)
{
bton=0;
off();
}
else if(val2==5)
{
on();
bton=1;
}
else if(val2==6)
{
bton=1;
off();

}
}
}
void dimmer()
{
bt=0;
if(dm!=1)
{
dm=1;
for(int i=5;i<=115;i++)
{
dim=i;
//delay(50);
if(dim>30)
{
delay(500);
}

}

}
else
{
dim=115;
//delay(50);
}

}

void brigth()
{
dm=0;
if(bt!=1)
{
bt=1;
for(int i=115;i>=5;i--)
{
dim=i;
if(dim<90)
{
delay(400);
}

}
}
else
{
dim=5;
delay(50);
}

}

void off()
{
dm=0;bt=0;
dim=115;
delay(50);
}
void on()
{
dm=0;bt=0;
dim=5;
delay(50);

}

Inga kommentarer:

Skicka en kommentar