Back to Parent

Outcome


The smart light and fan uses a photoresistor and temperature sensor to regulate the light output and the fan output. As the natural daylight in a room slowly starts to fade during dusk, the light gradually increases in brightness to keep the foot-candles consistent. Additionally, when the temperature reaches above a set temperature, the fan is activated until the temperature falls back below that temperature threshold.

The results of the project were mixed. The photoresistor seemed to work extremely well as depicted by the video. To make the LED adjust to the sensitivity of the photoresistor, I made two minor changes to the code; first, I created an inverse relationship between the sensor and the LED (90, 2000, 255, 0 - instead of90, 2000, 0, 255). Second, I turned off all lights and got a reading from the photoresistor of around 95 which I used to set (with a slight tolerance) the new threshold. Next, I turned on all of the lights to achieve a reasonable amount of light in the space and got a reading of around 2000, which I set as the upper threshold. 

One preliminary coding issue I encountered was the use of multiple void setup() and void loop() commands. I was previously unaware that there can only be one of each within a single sketch. Once figuring this out, I was able to take my two separate sketches (one sketch for the photoresistor + LED and one sketch for the temperature sensor) and combine them into a single sketch as seen in the coding below.

I had several troubles getting the temperature sensor to work accurately. It would often give inaccurate readings then jump all over the scale as if the temperature was fluctuating drastically every second. My intention was to connect a motor to the SparkCore which would turn on (as if it were a fan) above a certain threshold. Due to the complexities in wiring and coding, as well as the issues with the temperature sensor, I was unable to accomplish this. The temperature sensor did, however, work once in which case I was able to get an accurate reading and screenshot of the data. 

*photo credit (http://theawesomer.com/haiku-led-ceiling-fan/247920/)

Show Advanced Options
Image
Show Advanced Options
Image.thumb
Show Advanced Options
Show Advanced Options
Screen shot 2015 01 27 at 9.08.31 pm
Show Advanced Options
Drop files here or click to select

You can upload files of up to 20MB using this form.