(Another) DIY LED Controller - Simple Arduino Style

@ Yellobello.
Why make it more complicated? Why not just grab the 10v power supply in the first place? and use the same power supply als to power your arduino. Also, most of the time, you build your lights first, so this means you already have the 10v power supply already before you even build your arduino.

Eitherway, you diagram looks very cool. thanks for the suggestion.

c
 
You are probably right. I am just planning the setup right now and I didn´t have a 10v power supply.. just a 5v one. But I checked ebay and found out that a 10v supply is about the same price as the MAX680, so I´d rather go the way you suggested.
In case someone needs to make 10v out of 5v, this is the way to go.
Ahh and the diodes are not really necessary cause the transistors don´t allow the signal to go backwards since they are semiconductors, also.

Do you guys turn the LEDs off completely during the night by giving them the lowest possible signal (0V both D and P), or is it a good idea to disconnect them completely from the mains with a relay?

Other question: in order to save pins, would it be wise to hook up both, display and RTC by I2C? Or is it a problem to connect multiple I2C devices on the arduino?
 
Yello, you have good valid points.

Here is my take on it.

If suddenly you have issues with your arduino and you have to trouble shoot, then your lights will be out during trouble shooting. Right now, with the setup i have, i can remove the arduino completely and make my lights in full manual mode and on mechanical timers.

Example, right now, Im recoding my arduino to add temperature control. I have it in my desk right now totally isolated from my lights. it does not have dimming down effect just simple on and off. But it works while i added feature on my arduino...

Just a factor to consider, not saying, its the only way.
 
This is 100% not true!!!! You need to use the PWM of the arduino and that outputs 5V and the p's need 10V. You NEED a transistor. Read the whole thread! You will find that you need to hook them up the same. There are a couple ways to do it, but the input on the P needs to be 10V.

If you only hook it up to the arduino, the lights will not turn on.

So I hooked in the transistor and pot and cant get it to turn on the LEDs. If I apply 10v to the dimmer leads, it lights up fine but using the transistor circuit I get nothing. The dimming PWM pin is at full brightness 5V and I measure that at the Adruino pin. I measure about 2.5v between the 1K resistor and the base of the transistor. I am using the P driver. Any ideas?
 
Figured it out. The meanwell circuit was loading the circuit down and I was no longer providing 10v. My supply is not regulated.
 
Ya got to make due with what you have sometimes :). I had a pot in and adjusted the voltage to 10v then when attached and circuit was active, the voltage dropped. Once I bumped it up a little, it worked fine. Actually it accepted a pretty wide range and still functioned fine. I'm doing my fine tuning with the circuit set to max and using the trim pot in the meanwell to get the correct amperage.

I do have a strange issue though. When I run this with my wall wart power supply and the meanwell, it works fine. When I plug my USB in so I can mess with the sketch my LCD goes all screwy. The grounds from the meanwell and the wall wart are tied together but I guess adding the usb connection to my computer introduces some noise or something into it and hoses the LCD.
 
Need Help on LCD And RTC

Need Help on LCD And RTC

Hi katchupoy,

Need your help to continue my work (:

My stuff not yet complete i try to write a code for LCD & RTC that is the stuff i got now.

so i need try for upload ur code for my LCD and RTC. I use this code and delete some code;


/*

originally written by Christian, cptbjorn@gmail.com

modified by Cesar, caddnima@gmail.com,
https://sites.google.com/site/caddnima/
Version 1.00, 2012-03-13


*/


#define DS1307_I2C_ADDRESS 0x68 // address used for clock
#include "Wire.h" // library used
#include <LiquidCrystal.h> // library used



/* ********************************************************************************* */
/* * * */
/* * originally arduino pins 8, 9, 4, 5, 6, 7 are used, * */
/* * I have to use different arduino non pwm pins, so I can reserved the pwm * */
/* * pins for other use.(RS, EN , D4, D5, D6, D7 * */
/* * * */
/* ********************************************************************************* */
LiquidCrystal lcd(13, 12, 7, 6, 5, 4);




/* ******************************************************************************************************************** */
/* * * */
/* * R T C C L O C K D S 1 3 0 7 * */
/* * * */
/* ******************************************************************************************************************** */
byte decToBcd(byte val) // Convert normal decimal numbers to binary coded decimal
{
return ( (val/10*16) + (val%10) );
}


byte bcdToDec(byte val) // Convert binary coded decimal to normal decimal numbers
{
return ( (val/16*10) + (val%16) );
}

// 1) Sets the date and time on the ds1307
// 2) Starts the clock
// 3) Sets hour mode to 24 hour clock
// Assumes you're passing in valid numbers

void setDateDs1307(byte second, // 0-59
byte minute, // 0-59
byte hour, // 1-23
byte dayOfWeek, // 1-7
byte dayOfMonth, // 1-28/29/30/31
byte month, // 1-12
byte year) // 0-99
{
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0);
Wire.send(decToBcd(second)); // 0 to bit 7 starts the clock
Wire.send(decToBcd(minute));
Wire.send(decToBcd(hour)); // If you want 12 hour am/pm you need to set
// bit 6 (also need to change readDateDs1307)
Wire.send(decToBcd(dayOfWeek));
Wire.send(decToBcd(dayOfMonth));
Wire.send(decToBcd(month));
Wire.send(decToBcd(year));
Wire.endTransmission();
}


void getDateDs1307(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
// Reset the register pointer
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.writ(0);
Wire.endTransmission();

Wire.requestFrom(DS1307_I2C_ADDRESS, 7);

// A few of these need masks because certain bits are control bits
*second = bcdToDec(Wire.receive() & 0x7f);
*minute = bcdToDec(Wire.receive());
*hour = bcdToDec(Wire.receive() & 0x3f); // Need to change this if 12 hour am/pm
*dayOfWeek = bcdToDec(Wire.receive());
*dayOfMonth = bcdToDec(Wire.receive());
*month = bcdToDec(Wire.receive());
*year = bcdToDec(Wire.receive());
}



/* ******************************************************************************************************************** */
/* * * */
/* * D E F I N E : O N E S E C O N D * */
/* * * */
/* ******************************************************************************************************************** */

void onesecond() //function that runs once per second while program is running
{
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
lcd.setCursor(0, 0);
if(hour>0)
{
if(hour<=12)
{
lcd.print(hour, DEC);
}
else
{
lcd.print(hour-12, DEC);
}
}
else
{
lcd.print("12");
}
lcd.print(":");
if (minute < 10) {
lcd.print("0");
}
lcd.print(minute, DEC);
lcd.print(":");
if (second < 10) {
lcd.print("0");
}
lcd.print(second, DEC);
if(hour<12)
{
lcd.print("am");
}
else
{
lcd.print("pm");
}
lcd.print(" ");
delay(1000);
}



/* ******************************************************************************************************************** */
/* * * */
/* * S E T U P - D I S P L A Y * */
/* * * */
/* ******************************************************************************************************************** */

byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
Wire.begin();
second = 56;
minute = 57;
hour = 23;
dayOfWeek = 6; // Sunday is 0
dayOfMonth = 26;
month = 2;
year = 11;


/* ********************************************************************************* */
/* * * */
/* * this is where you set your time... * */
/* * 1) change the second, minute, hour, etc above * */
/* * 2) remove // below * */
/* * 3) and load this sketch to your arduino * */
/* * 4) after loading the sketch, put the // back again * */
/* * 5) and load this sketch again to your arduino, and save * */
/* * * */
/* ********************************************************************************* */
//setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);


lcd.begin(16, 2); // set up the LCD's number of rows and columns:
// lcd.print("12:00 80.6"); // Print a message to the LCD.
// lcd.print(char(223));
lcd.setCursor(0, 1);
lcd.print("blue:");
lcd.setCursor(8, 1);
lcd.print("white:");
}

But i can't compile and upload the code, it said error like this;

sketch_jul02a.cpp: In function 'void setDateDs1307(byte, byte, byte, byte, byte, byte, byte)':
sketch_jul02a:73: error: 'class TwoWire' has no member named 'send'

As of Arduino 1.0, the Wire.send() function was renamed to Wire.write() for consistency with other libraries.

sketch_jul02a:74: error: 'class TwoWire' has no member named 'send'

As of Arduino 1.0, the Wire.send() function was renamed to Wire.write() for consistency with other libraries.

sketch_jul02a:75: error: 'class TwoWire' has no member named 'send'

As of Arduino 1.0, the Wire.send() function was renamed to Wire.write() for consistency with other libraries.

sketch_jul02a:76: error: 'class TwoWire' has no member named 'send'

As of Arduino 1.0, the Wire.send() function was renamed to Wire.write() for consistency with other libraries.

sketch_jul02a:78: error: 'class TwoWire' has no member named 'send'

As of Arduino 1.0, the Wire.send() function was renamed to Wire.write() for consistency with other libraries.

sketch_jul02a:79: error: 'class TwoWire' has no member named 'send'

As of Arduino 1.0, the Wire.send() function was renamed to Wire.write() for consistency with other libraries.

sketch_jul02a:80: error: 'class TwoWire' has no member named 'send'

As of Arduino 1.0, the Wire.send() function was renamed to Wire.write() for consistency with other libraries.

sketch_jul02a:81: error: 'class TwoWire' has no member named 'send'

As of Arduino 1.0, the Wire.send() function was renamed to Wire.write() for consistency with other libraries.

sketch_jul02a.cpp: In function 'void getDateDs1307(byte*, byte*, byte*, byte*, byte*, byte*, byte*)':
sketch_jul02a:96: error: 'class TwoWire' has no member named 'writ'
sketch_jul02a:102: error: 'class TwoWire' has no member named 'receive'

As of Arduino 1.0, the Wire.receive() function was renamed to Wire.read() for consistency with other libraries.

sketch_jul02a:103: error: 'class TwoWire' has no member named 'receive'

As of Arduino 1.0, the Wire.receive() function was renamed to Wire.read() for consistency with other libraries.

sketch_jul02a:104: error: 'class TwoWire' has no member named 'receive'

As of Arduino 1.0, the Wire.receive() function was renamed to Wire.read() for consistency with other libraries.

sketch_jul02a:105: error: 'class TwoWire' has no member named 'receive'

As of Arduino 1.0, the Wire.receive() function was renamed to Wire.read() for consistency with other libraries.

sketch_jul02a:106: error: 'class TwoWire' has no member named 'receive'

As of Arduino 1.0, the Wire.receive() function was renamed to Wire.read() for consistency with other libraries.

sketch_jul02a:107: error: 'class TwoWire' has no member named 'receive'

As of Arduino 1.0, the Wire.receive() function was renamed to Wire.read() for consistency with other libraries.

sketch_jul02a:108: error: 'class TwoWire' has no member named 'receive'

As of Arduino 1.0, the Wire.receive() function was renamed to Wire.read() for consistency with other libraries.

sketch_jul02a.cpp: At global scope:
sketch_jul02a:170: error: expected constructor, destructor, or type conversion before '.' token
sketch_jul02a:171: error: expected constructor, destructor, or type conversion before '=' token
sketch_jul02a:172: error: expected constructor, destructor, or type conversion before '=' token
sketch_jul02a:173: error: expected constructor, destructor, or type conversion before '=' token
sketch_jul02a:174: error: expected constructor, destructor, or type conversion before '=' token
sketch_jul02a:175: error: expected constructor, destructor, or type conversion before '=' token
sketch_jul02a:176: error: expected constructor, destructor, or type conversion before '=' token
sketch_jul02a:177: error: expected constructor, destructor, or type conversion before '=' token
sketch_jul02a:193: error: expected constructor, destructor, or type conversion before '.' token
sketch_jul02a:196: error: expected constructor, destructor, or type conversion before '.' token
sketch_jul02a:197: error: expected constructor, destructor, or type conversion before '.' token
sketch_jul02a:198: error: expected constructor, destructor, or type conversion before '.' token
sketch_jul02a:199: error: expected constructor, destructor, or type conversion before '.' token
sketch_jul02a:200: error: expected declaration before '}' token

Can somebody help me? and am i missing somthing?

thanks
 
i try both of arduino 1.0 and ardunio 22. On 22 i got error message about wire.send.

But for the code i post can i use it to show the date and time on my LCD?

Does anyone ever build DS1307 RTC on breadboard? Coz now i'm using this one. My package from china not yet come.
 
i try both of arduino 1.0 and ardunio 22. On 22 i got error message about wire.send.

But for the code i post can i use it to show the date and time on my LCD?

Does anyone ever build DS1307 RTC on breadboard? Coz now i'm using this one. My package from china not yet come.


I think your problem is that you didn't copy the code properly. For example you didn't include the lcd library:

#define DS1307_I2C_ADDRESS 0x68 // address used for clock
#include "Wire.h" // library used
#include // library used

SHOULD READ

#define DS1307_I2C_ADDRESS 0x68 // address used for clock
#include "Wire.h" // library used
#include <LiquidCrystal.h> // library used

There are other errors but it would probably be easier for you to copy the original exactly. Code

Make sure you copy down to
} // END LOOP
 
Last edited:
PHP:
#define DS1307_I2C_ADDRESS 0x68   // address used for clock
#include "Wire.h"                 // library used
#include <LiquidCrystal.h>        // library used
 
In the past, I mentioned that I want to buy/build another one identical to what i had before so I can play with the sketch/code etc. So I can add features like temp, etc. And I believe, Fishman want to go along with me because he is an expert with coding and he does it for a living....

I think im going to do it soon. My ranco controller gave up and I believe i can use the existing temp sensor on it attach to my arduino. Unfortunately i cannot do it on my existing arduino setup, so i have decided that Im going to buy another set.

so here is my parts list again... this time, local US seller, and I believe cheaper than what i had before.

Arduino + 16x2 LCD + misc items = $40

DS1307 RTC = $9

5v Relay Module $10

if you dont want the combo kit above... you can also go with these...

Arduino $23

20x4 LCD $13.50

8 channel relay board with 5v coil. $16.75



.

Days after I ordered, I received the package/s. Im very happy with their fast and free shipping. And after delays after delays, i have finally started the phase 2. Which is actually just adding the temp monitor/controller function many of you guys already have.

I have created a separate page from my website to keep it clean. So if you are just starting, please follow me here...
Arduino Reef Controller (again). All comments and suggestions will still be in this thread, Hoping that this will help others too while I am relearning this Arduino again.

19 months have passed and my original arduino controller is still running strong. Still doing what its doing, wavemaker works and ramp up and down of lights still works.

so hopefully you will follow along.
 
Last edited:
So are you going to start from scratch? I see that you linked to the 1.0.1 Arduino software. That was what dorfed me up in the beginning because I didn't know that a lot of stuff changed when version one came out.

I still have my project scattered all over my desk. It works but it's kind of meh. I am wondering why the temp sensors and the clock are on different pins if they are one wire devices. There were issues with the temp sensors not updating when the LEDs were in ramp cycles. Ronnythereefer got me squared away on that one. One thing is for sure, I learned a lot. I had never touched anything like this before. This is addicting.

Can't wait to see where you take this project and look forward to seeing the new code. :)
 
Mike,

to be honest I dont know about this 1.0.1. Im just documenting every step of the way, failure and success so that others will learn. You are several step ahead of me, so i cannot relate on your problems. But soon, I will probably asking the very same questions you are asking now.

I dont even remember what i used before. Crap, does it matter? so if its 1.0.1. now, what is it 19 months ago? I should have saved it somewhere.
 
Mike,

I just found out that i was using 0022 version on my original build. Im not sure if 1.0.1. will make a difference on my fifth build. We will see. If worst come to worst, i will just use 0022.
 
I'm running 022 just because I had to to get it to work with the code here and the libraries that I found. It would be nice though to be up to date on the latest Arduino code but as long as it work I really don't care. I don't know what they changed when they went to version 1 but I could not get it to compile at all.

I've spent the better part of tonight trying to lay out how to route all the wires for this mess on my desk. I want to put it in a project box but wiring neatly was never my strong point. :hmm4: Interfacing with the Meanwell is throwing me as I'd like to do what the folks here have done and kill it's power at night with a relay. Did you do that?
 
Back
Top