Guiding night-light

Made by ankitaa

How can I get to the bathroom in the middle of the night without bumping into things in my way? If the light switch was near me, I could easily switch it on before I get off the bed, but that's almost never the case. What if there was an intelligent light system that lit up when it detected that people have gotten off their bed when it is still dark? The goal of this project is to realize an intelligent night-light that does just that. No more accidents in the dark!t

Created: January 28th, 2015

0

This circuit is designed so as to be part of the home automation system - it can help you find your way if you wake up in the middle of the night. It therefore detects if someone has gotten off the bed (force resistor is not pressed - low force - someone has gotten up) and at the same time if it is night (photo resistor shows darkness) and then switches on the 'guide lights' in this scenario. Later when someone gets back on the bed (force resistor reads the weight) , it switches off the light. It also switches off the light if it detects that it is day-time.

COMPONENTS USED :

Jumper wires

Spark micro-controller

1 red LED pin

1 force resistor

1 photo-sensitive resistor

1 1kohm resistor

2 10kohm resistors


Here is the code for it :

0
// Define input pins
int force = A1;
int light = A7;

int forcereading = 0;
int lightreading = 0;

// Define an outut pin
int ledPin = D1;

void setup()
{
  // Create a cloud variable of type integer
 Spark.variable("forcereading", &forcereading, INT);
 Spark.variable("lightreading", &lightreading, INT);

  // Set up the pins for input and output
  pinMode(ledPin, OUTPUT);
  pinMode(forcereading, INPUT);
  pinMode(lightreading, INPUT);
}

void loop()
{
  // take reading from force resistor and save it in 'forcereading'
  forcereading = analogRead(force);

  // Use analogRead to read the photo cell reading and save in 'lightreading'
  lightreading = analogRead(light);

  // if someone gets off the bed while it is still dark, switch on the night light
  if (forcereading<100 && lightreading<2000){
  //switch on night lights to guide him/her to bathroom
  digitalWrite(ledPin, HIGH);

}

  // if the pressure on the bed increases (person gets back on) and the room is still dark(its night),
  //then switch off the night light.
  else if(forcereading>1000 && lightreading<2000){
    // delay to wait for person to decide if he is ready to sleep?
    delay(20000);
    //switch off night lights
    digitalWrite(ledPin, LOW);
  }
// if it is day-time, switch off the light (in case it is on for some reason)
  else
  {
  digitalWrite(ledPin, LOW);
  }

}
Click to Expand
x
Share this Project


About

How can I get to the bathroom in the middle of the night without bumping into things in my way? If the light switch was near me, I could easily switch it on before I get off the bed, but that's almost never the case.

What if there was an intelligent light system that lit up when it detected that people have gotten off their bed when it is still dark?

The goal of this project is to realize an intelligent night-light that does just that. No more accidents in the dark!t