My Dad has been doing some remodeling of his living room recently and, as part of this, bought bookshelves and some lights to go with them. He wanted some way to turn them on without having to deal with the little switch included with the lights so he thought it would be nice if the lights turned on in the evening on their own. So the task fell to me and and I happily accepted.
This project is actually fairly simple as only a few cheap parts are needed and little coding is required. There is a real danger of electrocution with this project however as we are dealing with voltages from 120V to 220V ( depending on where you live). Please be sure to the necessary precautions when working with live wires for this and any project you take on.
I am using the following parts for this project:
- Arduino Uno R3 (for prototyping) and an Adafruit Trinket 5V – Mini Microcontroller (finished product)
- light sensor
- Seed Grove Relay
- Adafruit Perma-Proto Small Mint Tin Size Breadboard PCB
- GA1A12S202 Log-scale Analog Light Sensor
- Dollar store extension cord (for prototyping)
- IR Motion Sensor
Since I didn’t have access to the lights when I started nor did I have a light sensor handy, I started by creating a prototype to test the relay with an Adruino Uno R3. I wrote a simple loop that closed the the relay, waited a second then opened it again. This was repeated so long as power was supplied to the Arduino.
For the next prototype I simply added a sensor I had lying around to test controlling the relay based on the input form a sensor. I sensor I chose was a IR motion sensor. The end result was an extension cord that would send power to whatever was plugged into it when motion was detected. I’ll post an update once the light sensor arrives and I find time wire up a circuit for testing.