The circuit contains a relay interfacing with 12v power supply and LED strip. Can the brightness for this strip of LEDs be controlled using the analogWrite
command?
This works perfectly for a single LED, but when i replace the LED with a relayed LED strip with its own adapter, it doesnt produce any perceivable output
-
2Relays are really slow, as they are mechanical. You can't use analog-write on them. Follow something like this tutorial (except with only one color, instead of three)– GerbenMay 19, 2015 at 18:19
-
Tried this tutorial and well it never really fully responds to a tweaked example code from the site. I am powering the board through usb and thats the only difference. Basically haven't connected Vin and adapter connection which is directly supplying 12v to led. Could that be a problem that even anlaogWrite of 0 and 200 are not producing much of a difference, very very mild response– CollectiveumMay 20, 2015 at 20:12
2 Answers
As Gerben said relays are only for on/off control. If you need to fade led you should use transistor.
What kind of transistor?
It depends on power consumption (how many LEDs).
How to connect Arduino, LEDs, transistor?
This is schematics how to connect the strip. As i assume resistors are already on the strip.
And little bit simpler image :)
-
Most transistors don't have the gain, or ratio between "big current" and "small current" to drive a very hefty LED strip when there's a 2K resistor on the base. In the situation you have drawn where you also have a series resistor on the LED strip it might work, but some real LED strips of the sort the OP might be controlling with a relay are high current devices that can want a fair fraction of an amp, or more. Oct 17, 2015 at 0:20
-
Yes @ChrisStratton as i wrote it depends on power consumtion. The drawings are just to get an idea of how it works.– MartynasOct 18, 2015 at 10:24
-
And big current its not 10amp ;)) thats in milliamps ;) but regard mA from MC;)– MartynasOct 18, 2015 at 10:25
Yes!
In the simpler image replace R2 with a 10 Ohm resistor and Q1 with a N channel Logic Level FET. This will allow you to switch (PWM) amps with R1 removed.
My LED strips pull about 3 amps at 12V. Depending on the FET you use you may have to add a heat sink. You will need to connect the low side (Ground) on the Arduino power supply to the low side on the power supply for the LED strip. The Arduino can then operate at 5 volts and the LED at 24V or whatever depends on the rating of the MOSFET. I would suggest using one of the PWM outputs, they will work fine with this circuit. This works for motors but additional parts will need to be added.
Enjoy.