![]() |
Improved Arduino LED lighting code
I wasn't happy with any existing Arduino code for LED control so I wrote my own. I think it's quite nice though it needs polishing and probably some features added. It does light timing, sunrise/sunset fading and all that jazz.
Some improvements over existing code:
It works great for me. I'd love feedback, error reports, suggestions, free beers, etc. Post in the thread or PM me. I hope this will be useful to people! :thumbsup: Get the code: Latest version Libraries bundle Installing libraries: The libraries that don't come with the Arduino environment by default are bundled in the zipfile above. Just extract that zip into the libraries folder inside your sketchbook folder and then restart the Arduino IDE. If libraries doesn't exist, create it first. Until I get around to writing documentation just post or PM installation questions/issues and I'll try to help. Latest Version: 12/11/2011 (only documentation changes, no need to upgrade!) |
I would try it. But I'm not sure how to hook up my rtc. Could you e plain how or link me to a deceit walkthrough?
|
Quote:
Here's a tutorial that might be applicable Adafruit also sells an RTC breakout board kit with everything you need except wires for under $10. I don't have one but I modeled my RTC circuit after theirs and it works great, so might be an option if you want to add an RTC to an existing setup. |
I'll give it a try! Took me nearly an hour to hunt down and install the extra libraries, but I got the code to compile without issue. I'll hook up the Dueminlanove this weekend and see what happens. Good job sink- Now if you could only show me how to integrate that coding into the controller that I built, that would be awesome!
|
Quote:
I'd love to make a bundle with the required libraries but I'm not sure if the licenses permit it. In the meantime I'll edit the original post with links to the needed libraries. Thanks for pointing out that task might not be trivial. I'm willing to help with any driver integration you need. Do you mean the RTC or the code? |
Sink,
I found the TimerOne and Time libraries at Arduino.cc, so I think you could zip them up together with your code and be good to go. There's one thing you need to fix though, your code cannot be unzipped and moved directly into the Arduino IDE. The IDE will not recognize the folder until it is renamed. I had to change the name of the folder to "akl_tank_control" and the file name to "akl_tank_control.pde" and then it would open and compile properly. This is detail that may cause trouble for people who are not familiar with some of the Arduino IDE's file naming requirements. I'll have to shoot you a PM with the coding for my controller. It works great as is, but I like the fact that your code updates the PWM every second, instead of once per minute. I've got the hardware side of things nailed down but I could use your help to improve the software. Here's a photo of the controller board- without the 16x2 LCD on top. http://i861.photobucket.com/albums/a...a/IMG_1366.jpg I've got enough boot loaded ATMEGA328's to build 30 more, and a newer design that supports the MeanWell ELN-P's as well as my Cat4101's. Maybe a trade- Chips or a completed controller for software? |
Quote:
Quote:
Quote:
|
Sink,
I loaded the code into my Duemilanove and connected it up to my Cat4101's, Looks good so far. I made some changes to the code to run the leds at max (1023) all day,and set the night time level to a minimum (20) for moon lighting at night. I think a pwm value of 20 works out to be a hair less than 2%. I should know by 10pm whether or not the leds will continue to run at such a low setting. I did notice that there's something amiss with the time display in the serial monitor. The time displayed is 1 hour less than the correct time on my PC. Any idea what's causing that? Must be something to do with the DS1307 and daylight savings time? |
Quote:
Quote:
|
Quote:
I'll have to try that sketch. I just adjusted the start and stop time in the main sketch to compensate for now. hehe! |
Quote:
On battery power the DS1307 shuts down all functions except for keeping the clock running so it can run for 5+ years on a single coin cell. Pretty nifty. |
Very cool - I'd like to upgrade my controller with the new code once it is worked out!
|
Quote:
Well, we'll have to see what "coding magic" "Sink" can pull off! LOL Then I'll show you how to reprogram the controller. He's got a day job- so let's not rush him.LOL |
Sink,
I uploaded the TimeSet code.....Worked perfectly. I also uploaded the TankControl code again after lowering the minimum PWM state to "5" and stting the fade duration to 1 hour. All I can say is "WOW!" The dimming is completely linear, seamless, and totally natural looking. That has got to be the best Dimming Simulation that I've ever seen! I now have 90 little "moon lights" over my tank. Too cool! Thanks so much for creating and posting the codes!:biggrin::proud: |
Wow, you are getting me excited to download this to my arduino. I need to get that RTC installed.
|
| All times are GMT. The time now is 12:28 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.