Digital House

Made by shianhey

Created: January 28th, 2015

0

Goal: 
The device can be settled in rooms of house to detect light. When outdoor lighting is insufficient or the curtains is closed, the light sensor can automatically open the lights to light up interior space. User can also manually press a button (force sensor) to turn on or off the light.

Process documentation: 
Spark Micro controller
Breadboard
Force Sensor*1

Light Sensor*1

LED*2

Jumper Wire*5

10K Resistor*1


0
int photoCellPin = A0;
int fsrPin = A1;

int photoCellReading = 0;
int fsrReading = 0;

int ledPin = D0;

int ledBrightness = 0;

void setup(){

  pinMode(ledPin, OUTPUT);

  Spark.variable("force", &fsrReading, INT);
  Spark.variable("light", &photoCellReading, INT);

}

void loop() {

  fsrReading = analogRead(fsrPin);
  photoCellReading = analogRead(photoCellPin);

  if((fsrReading>1000)||(photoCellReading<50)) ledBrightness=255;
  else ledBrightness = 0;

  //else ledBrightness = 0;

  analogWrite(ledPin, ledBrightness);
  delay(100);
}
Click to Expand
0
0
x