DIY LED controller

BobCajun

Well-Known Member
I made a cool LED PWM dimmer from an Arduino Nano microcontroller. It was cheap and relatively easy. A bit of screwing around connecting everything up but nothing too bad.

So I got some Nano clones (DCCduino), transistor output optocouplers and 250 ohm resistors. I found this idea from the second post on this page. The optocouplers were about 80 cents each. The resistors were a dollar something each because I got 5w ones to be on the safe side. I guess I didn't need that high a wattage but for a dollar something who cares? So I got 10 of each. The couplers and resistors cost me about $50 with UPS shipping, which was $25. Figured I might as well get 10 to make it worth the shipping. I have 5 Nanos and can get another 5 locally if I need them.

So I slapped it together and it worked perfectly. I set it for 400 microseconds on and 800 off, a 33% duty cycle. I've read a patent that claims that such a pulse setting would increase yield by about 50% while using about 1/3 the power. Here's the patent, you can look at the graphs to see what I mean. Will it actually work? Guess I'll soon find out. Could be total BS or only work with certain plants or very low light levels. It sounds too good to be true but it was worth me checking out. It certainly looks a lot dimmer. Will the growth be slow because of that or will it in fact be boosted by 50%? If I notice slow growth or yellowing I'll put it back to normal. With that much dimming, it would be like about 150w per sq meter, so obviously if the patent is wrong the plants will barely grow.

At least I have dimmers I can set up any way I want. I can program in gradual change of brightness to mimic sunrise and sunset, or change the spectrum at certain times, if I used mixed monos. Having a programmable microcontroller on your dimmer leads is a vast step up from a potentiometer. They cost me like $13 each to make, which is actually pretty much the same as you can buy a simple rotary potentiometer for. I can do lots of stuff with Arduinos. I can do only one simple thing with a potentiometer.

BTW, you really do need to reverse the PWM programming like the linked post says. I checked it to make sure by making the off time in the code, which would really be on time after going through the coupler, only 100 micros and it was dimmer than when I had it at 400. Here's the code as it is shown in the Arduino site. You just change the 100 and 900 to whatever you want. Since it needs to be reversed, I used 800 and 400.

void setup()
{
pinMode(13, OUTPUT);
}

void loop()
{
digitalWrite(13, HIGH);
delayMicroseconds(100); // Approximately 10% duty cycle @ 1KHz
digitalWrite(13, LOW);
delayMicroseconds(900);
}
 
Last edited:

Jp.the.pope

Well-Known Member
I made a cool LED PWM dimmer from an Arduino Nano microcontroller. It was cheap and relatively easy. A bit of screwing around connecting everything up but nothing too bad.

So I got some Nano clones (DCCduino), transistor output optocouplers and 250 ohm resistors. I found this idea from the second post on this page. The optocouplers were about 80 cents each. The resistors were a dollar something each because I got 5w ones to be on the safe side. I guess I didn't need that high a wattage but for a dollar something who cares? So I got 10 of each. The couplers and resistors cost me about $50 with UPS shipping, which was $25. Figured I might as well get 10 to make it worth the shipping. I have 5 Nanos and can get another 5 locally if I need them.

So I slapped it together and it worked perfectly. I set it for 400 microseconds on and 800 off, a 33% duty cycle. I've read a patent that claims that such a pulse setting would increase yield by about 50% while using about 1/3 the power. Here's the patent, you can look at the graphs to see what I mean. Will it actually work? Guess I'll soon find out. Could be total BS or only work with certain plants or very low light levels. It sounds too good to be true but it was worth me checking out. It certainly looks a lot dimmer. Will the growth be slow because of that or will it in fact be boosted by 50%? If I notice slow growth or yellowing I'll put it back to normal. With that much dimming, it would be like about 150w per sq meter, so obviously if the patent is wrong the plants will barely grow.

At least I have dimmers I can set up any way I want. I can program in gradual change of brightness to mimic sunrise and sunset, or change the spectrum at certain times, if I used mixed monos. Having a programmable microcontroller on your dimmer leads is a vast step up from a potentiometer. They cost me like $13 each to make, which is actually pretty much the same as you can buy a simple rotary potentiometer for. I can do lots of stuff with Arduinos. I can do only one simple thing with a potentiometer.

BTW, you really do need to reverse the PWM programming like the linked post says. I checked it to make sure by making the off time in the code, which would really be on time after going through the coupler, only 100 micros and it was dimmer than when I had it at 400. Here's the code as it is shown in the Arduino site. You just change the 100 and 900 to whatever you want. Since it needs to be reversed, I used 800 and 400.

void setup()
{
pinMode(13, OUTPUT);
}

void loop()
{
digitalWrite(13, HIGH);
delayMicroseconds(100); // Approximately 10% duty cycle @ 1KHz
digitalWrite(13, LOW);
delayMicroseconds(900);
}
Thank you :) do you have an external power source for the arduino?
 

BobCajun

Well-Known Member
Not sure if i follow the circuit.
Do you have 10v supply to optocoupler?
To reply to you and JP, I powered it with a 9v adapter I had. That's right in the voltage range that they can use, 6v being the least and 20 the most. 9v is just about right.

There is no 10v power supply involved. The current comes from the driver itself. All you have to do is hook the leads up to the output side of the coupler. The coupler simply has a transistor in it that acts as a gate.

Though I used Nano type Arduinos, you might be better off buying the normal size Uno type, because the Nanos have no adapter jack and are quite small to work with. They are cheaper though. If you do try to put one together and need help I don't mind providing advice. It'll be easier if you get a breadboard too, which is a plastic board with holes in it to stick components into. I didn't get one and it was pretty troublesome without it. I just have the parts wired to the Nano but just out in the open. I put the Nano in a snack baggie and zipped it so just the wires are sticking out, to protect it somewhat. But yeah it's just the coupler and the resistor hanging off it by the wires. I just wanted to make sure it would work. I could make a better one if I wanted to put more work into it.
 

robincnn

Well-Known Member
Looks like the guy has this circuit.
upload_2016-3-18_9-5-25.png
What do you think ?
When you do digitalWrite(13, HIGH); then looks like optocoupler shorts the Dim+ and DIM- so lights off
When you do digitalWrite(13, LOW); then looks like optocoupler open circuit for Dim+ and DIM- so lights on

If it is working like this then it has issues. Driver other than LDD may not like the Dim+ and DIM- short.
open circuit for Dim+ and DIM- will give over 100% driver power, which is fine.

1lhz freq is too fast for cobs and driver. I do not think it will be 100% dark when lights on/of so fast. I hope i am wrong. Good luck.

The commented code is similar to what you did. Analogwrite is another method of pwm but not easy to calculate what on/of periods will be.
 
Last edited:

Greengenes707

Well-Known Member
I have a question.
For the external power form the arduino. Does that power go off, or are you keeping the arduino on the whole time, and just the lights go off.
I use a storm and that is the problem. If you integrate it into a light and use the lights power source, when the light goes off, so does the arduino, and with the storm, all settings get lost so when it comes back on sunrise and sunset are gone. So I have been using it as a room controller vs into each light because of that.
Does a standard arduino hold its settings if powered off?
 

BobCajun

Well-Known Member
I have a question.
For the external power form the arduino. Does that power go off, or are you keeping the arduino on the whole time, and just the lights go off.
I use a storm and that is the problem. If you integrate it into a light and use the lights power source, when the light goes off, so does the arduino, and with the storm, all settings get lost so when it comes back on sunrise and sunset are gone. So I have been using it as a room controller vs into each light because of that.
Does a standard arduino hold its settings if powered off?
Nope, you plug the adapter in and the arduino is powered all the time. The on/off state of the lights is based solely on the PWM signal it puts out. It never powers off unless you unplug it. I suppose the adapters would add cost to the $13 I stated, but you could run several from one adapter I would think. They don't use much current.
 

BobCajun

Well-Known Member
Looks like the guy has this circuit.
View attachment 3634946
What do you think ?
When you do digitalWrite(13, HIGH); then looks like optocoupler shorts the Dim+ and DIM- so lights off
When you do digitalWrite(13, LOW); then looks like optocoupler open circuit for Dim+ and DIM- so lights on

If it is working like this then it has issues. Driver other than LDD may not like the Dim+ and DIM- short.
open circuit for Dim+ and DIM- will give over 100% driver power, which is fine.

1lhz freq is too fast for cobs and driver. I do not think it will be 100% dark when lights on/of so fast. I hope i am wrong. Good luck.

The commented code is similar to what you did. Analogwrite is another method of pwm but not easy to calculate what on/of periods will be.
Not sure exactly how it works. I think I know what you mean though. You need a driver with PWM 0-10v dimming capability.

About the 1kHz dimming limit. I did read something like that. Fortunately, my setting of 400 mics on and 800 off works out to a little less than 1 kHz. Now ifit were 400/400 then it might be a problem, I don't know. What happens if you exceed the limit?

Here's another thing. You would think that when the coupler transistor gate closes that it would be the same as the leads just being capped off, which results in full light. But you also are thinking that when the gate is open 10v goes through and 10v is also supposed the be full light. So you would think that it would be full light all the time. I really don't know why it actually works, but it apparently does.

BTW, I keep the drivers in a closet, to keep the heat down in the room, and I thought they were 0-10v but when I went to attach the dimmer I saw that it's really 1-10v, which means that at lowest signal voltage, or open circuit, it's still on at 10% brightness. So I don't know if that will effect the results or not. Maybe it needs full darkness between pulses. On the other hand, maybe it's better. Light is then continuous but only at saturating levels part of the time. That may be better somehow and probably easier on the LEDs, though I'm just guessing about that.
 
Last edited:

Greengenes707

Well-Known Member
Nope, you plug the adapter in and the arduino is powered all the time. The on/off state of the lights is based solely on the PWM signal it puts out. It never powers off unless you unplug it. I suppose the adapters would add cost to the $13 I stated, but you could run several from one adapter I would think. They don't use much current.
Ya, unfortunately what I thought. The concern is having all settings lost when a light and controller go off if the controller is built in. Need to break into the code to change the start up setting I guess.
IMG_6496.jpg
 
Last edited:

BobCajun

Well-Known Member
Ya, unfortunately what I thought. The concern is having all settings lost when a light and controller go off if the controller is built in. Need to break into the code to change the start up setting I guess.
The settings stay in place even with power off. The code you upload stays in there. It wouldn't be much of a product if every time you unplugged it from the USB or adapter you lost everything you put on it. Doubt they'd sell many. You don't need to break into any code, because you can change the code anytime you want. They have invented solid state storage. It's not like arduinos work on RAM only.
 

Greengenes707

Well-Known Member
The settings stay in place even with power off. The code you upload stays in there. It wouldn't be much of a product if every time you unplugged it from the USB or adapter you lost everything you put on it. Doubt they'd sell many.
That is what I asked the first time. And I still don't think you are getting me.

So you are saying...that when you write your code...the sunrise and sunset times are in that code. and that to change the rise/set time...you would need to re-write code??

Cause I am saying that when I set the controller to rise at 6:30pm instead of 12:00am(stock time)...then the arduino is turned off..it goes back to 12:00am. Not that you have to rewrite anything.
 

BobCajun

Well-Known Member
That is what I asked the first time. And I still don't think you are getting me.

So you are saying...that when you write your code...the sunrise and sunset times are in that code. and that to change the rise/set time...you would need to re-write code??

Cause I am saying that when I set the controller to rise at 6:30pm instead of 12:00am(stock time)...then the arduino is turned off..it goes back to 12:00am. Not that you have to rewrite anything.
Okay, you stumped me. For that, you'd have to go to an Arduino forum I suppose. My knowledge of them is limited to making a dimmer that pulses regularly all the time. Maybe you can't really program gradual sunrise/sunset, who the hell knows? I would think you could, pretty sure I read about people with aquariums doing that. How you actually do it, haven't got a clue. I only learn as much stuff as I need to know at the time, which right now is how to make a pulse PWM dimmer.
 

robincnn

Well-Known Member
@Greengenes707
The programming does not away. It is stored. When you power it off and power it on again the will boot and then execute setup function and then will loop through the loop function.
I think the internal clock resets with power off. But looks like there is a easy fix RTC Mod
Pretty easy to keep it powered on. Arduino can be powered by a USB if connector to computer or 7-12V. I use a APV-12-12
 

Greengenes707

Well-Known Member
@Greengenes707
The programming does not away. It is stored. When you power it off and power it on again the will boot and then execute setup function and then will loop through the loop function.
I think the internal clock resets with power off. But looks like there is a easy fix RTC Mod
Pretty easy to keep it powered on. Arduino can be powered by a USB if connector to computer or 7-12V. I use a APV-12-12
I'm not worried about powering it. They are no harder to power than a fan. I just don't want to have to keep it powered when when lights are off. I want it to go off..and to start up as if it never went off once lights come on again. Blue LCD screens(even green ones) on in the dark cycle is not a good thing. And having it integrated in the light so you use the same plug...which is usually on a timer is the other goal.
How to get around those has been my issue in the past. Just wondering if anyone has ran into the same or has gotten around it.
I'm here to learn on arduinos.
 

BobCajun

Well-Known Member
I'm not worried about powering it. They are no harder to power than a fan. I just don't want to have to keep it powered when when lights are off. I want it to go off..and to start up as if it never went off once lights come on again. Blue LCD screens(even green ones) on in the dark cycle is not a good thing. And having it integrated in the light so you use the same plug...which is usually on a timer is the other goal.
How to get around those has been my issue in the past. Just wondering if anyone has ran into the same or has gotten around it.
I'm here to learn on arduinos.
Well why can't you just program it to do such and such a routine on startup? If your program is to start from zero brightness and gradually increase, stay at full brightness for so many hours and then gradually go back to zero then I guess you would just write it so it stays at high (low if it uses optocoupler) for so many hours, using whatever graduations they have available, like with the setting for so many microseconds. If all they can use is microseconds then I guess each hour would be 3600000000 or whatever. I don't know how to do the gradual brightness thing, but I've seen videos of it with a single LED, cycling up and down, as a demonstration, so it's possible.

Here, try this page, might be something useful there. You may have already found this page.
 
Last edited:

BobCajun

Well-Known Member
Cause I am saying that when I set the controller to rise at 6:30pm instead of 12:00am(stock time)...then the arduino is turned off..it goes back to 12:00am. Not that you have to rewrite anything.
The Arduino doesn't have clock in it, as far as I know. You just use a timer to turn it on and program it to do whatever on start. I guess you need one of these if you want it to have a clock. Maybe that's what you were talking about. Apparently it has a trickle charger, so even when the power is off it would run.


These appear to be better ones. The batteries will apparently power these for about 10 years btw. So I wouldn't bother with a separate power supply.

Also, about the blue LCD screen. Blue light doesn't effect flowering. Maybe you can find one with a flip top though. There's a small red LED on the Arduino but presumably it would be hidden inside something.
 
Last edited:

BobCajun

Well-Known Member
There's some code on this page that uses "alarm" to make the Arduino turn the lights on at a certain time and do the sunrise routine. I assume you can use it to activate other tasks at preset times. This may actually avoid the need for normal timers. The drivers would be plugged in all the time but the light would only be produced when the Arduino alarm goes. There would be slight power loss from the drivers that way I suppose, unless they only get hot when the dimmer is actually on. This page has some supposedly improved code for this type of thing and some libraries you can DL and install.
 
Last edited:
Top