Improved Arduino LED lighting code
Planted Tank Forums
Your Tanks Image Hosting *Tank Tracker * Plant Profiles Fish Profiles Planted Tank Guide Photo Gallery Articles

Go Back   The Planted Tank Forum > Specific Aspects of a Planted Tank > DIY


 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 09-06-2011, 11:49 PM   #1
sink
Algae Grower
 
PTrader: (2/100%)
Join Date: Jun 2011
Location: Boston, MA
Posts: 148
Default 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:
  • Shorter and simpler
  • Accurately set clock from a script on your PC. You don't need to modify any code or upload any sketches!
  • Much, much smoother dimming, especially at the low end (due to a combination of higher resolution PWM output and every-second dimming adjustment instead of every-minute).
  • Higher resolution PWM also means you can dim your LEDs down to a lower intensity than before if your driver is capable. I've found I can dim my LEDs down far enough to be used as moonlights.
  • Flexible timing logic. You can do anything you want (with minor modifications) so long as it's on a 24hr cycle.
There are also some limitations:
  • Your Arduino needs to have either a DS3231(eg: ChronoDot) or DS1307 Real Time Clock chip connected via I2C (because I have one of those). These are probably the two most common RTC chips.
  • It only provides 2 PWM outputs (because I only have 2 LED strings). Of course you can modulate as many strings as you want from a single PWM signal but they'll modulate in unison.
  • It should work with the Arduino Duimilanove/Uno and probably any other micro-controller that uses the Atmega168/328 chip. In particular it will not work as-is with the Arduino Mega due to a difference in the onboard timers.
  • It depends on a few libraries but I've bundled them up in a download link below.
  • Only compiles with versions 0022/0023 of the Arduino IDE, not version 1.0 (yet!)

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!

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:
05/2014 -- O2surplus has made some significant improvements to this code, adding LCD and temp sensor support, please see his posts later on in this thread for the code.

Last edited by sink; 06-24-2014 at 09:54 PM.. Reason: updates!
sink is offline   Reply With Quote
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:00 PM.


Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright Planted Tank LLC 2012