Light Timer Project: First draft of code

I posted about this project about a week ago. I’m building a system to turn a string of lights on and off during certain time periods during the day. To recap, here are the main objectives:

  • Turn on and off the string of lights automatically during specific times during the day.
  • Have an LCD display the current date and time, as well as when the lights are going to change state next.
  • Allow for manual control of lights.
  • Allow change of time periods through use of menu buttons and LCD.
  • Allow enable/disable for weekend automation.

Bugs pop up from time to time, but I’m slowly going through them. It’ll be a few days before I can say these objectives are complete.

I haven’t been documenting the progress very well because I get excited after finishing one piece of it and then hurry onto the next. Here’s what I’ve got up to this point.

1Before I received the parts for the real time clock (which I’ll now be calling RTC), I was playing around with the LCD I already had from Greg the robot. When I got the parts and tried hooking it up alongside the LCD, the RTC didn’t work. After a couple hours of frustration, I pulled it all apart and started over. It was just a connection problem and had nothing to do with the LCD. It’s easier to work with one thing at a time.

2Once I confirmed that the RTC was working and that it kept going after the Arduino was unplugged, I wrapped it all up in electrical tape. The coin battery lasts for years (I think I read 9 years somewhere) so I won’t be needing to get to anything wrapped up in there any time soon. After that, I reconnected the LCD, along with the buttons I was playing with.

3Programming took a solid 4 hours. The biggest issue was getting the logic right to turn on the light (the blue LED I’m using for the testing phase). There is a library that would accomplish this, but I already had an idea of how I was going to go about it.

Along the way, I made a few notes that will probably be posted somewhere near the panel:

  • The time will remain correct if powered off. However, any changes through the menu (schedule, weekend setting, override) will be lost.
  • It expects you to enter times when you’ll be around and it’s dark. You cannot set time ranges overnight or around noon.
  • Be sure to completely exit out of the menu as the light timer will not function until it is on the default screen (Default screen displays time and date). [I will address this by having the menu timeout after some time.]

So there’s still some more work to do! Stay tuned!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s