How can I get the 5v outputs to switch 12v outputs on this project ?

I've finally finished the programming on my strobe LED project and got it working on an attiny85 and am just about ready to solder this up on some protoboard. But im going to want to replace these leds with led strips that run on 12v, but the attiny runs 5v and so are it's outputs.

I will power this off a 3s lipo which would give me the right power for the LED strips, and I guess I need to use a voltage regulator to power the tiny with 5v, but im confused as to how to send the output and power these led strips to blink. What would be the best solution here ? and how would you guys do this?

here is a photo (if that helps at all) http://i.imgur.com/jGm09mN.jpg

Thanks

Give the LEDs their power from the external source but below the LED, ie on the ground side, put an NPN transistor of some sort. Then your digital io from Arduino switches the transistor base (thru a resistor), which in turn switches the low side of the LED circuit.

Something like ..... this.... but with the right voltages and not necessarily that model of transistor.

You can use 4 discrete transistors and base current limit resisitors, or a single chip, transistor array with built in limit resistors such as ULN2003 to replace all 8 of those components.

thanks guys, so transistors are the way to go. Any idea what type / number transistor I should use?

driz:
Any idea what type / number transistor I should use?

Well I think CR was telling you that......

Yup, the ULN2003 is used in just about every appliance I have torn down for work to drive relays. It's a great little chip and the only additional advice I'd give is that there are current limits for Darlington-arrays like the 2003A.

So review the data sheet and your LED-driving current requirements carefully to ensure that you are not exceeding the current limits of the 2003A or switch to a beefier transistor or perhaps even a electromechanical relay. It all depends on what you are trying to do - for example, dimming via PWM will not play well with most/all electromechanical relays, while simple on/off may be perfect for a relay and not so perfect for the solid state relay (heating).

You will still need a chip like a 2003A to drive a electromechanical relay, however. And, unless the chip has a built-in snubber, add a snubber diode to limit inductive kickback from the relay from damaging the 2003A.

How'd relays come into this?

JimboZA:
Well I think CR was telling you that......

Understood thank you, but I wont be needing those resistors as the led strips power direct from 12v and have their own.

Also in my sketch I am using PWM to dim the LED's, is this still possible using single transistors ?

Yes, you can PWM the transistors.

CrossRoads:
Yes, you can PWM the transistors.

Great news, thanks all for the help!!

CrossRoads:
How'd relays come into this?

All a function of current, no? Isn't it typically cheaper to use a electromechanical relay for higher currents as long as you don't need to PWM quickly? Hence my recommendation to have a look at the datasheet vs. the expected power draw of the LED string. The ULN2003a is usually good for up to 500mA, which typically gets you about 25-50 small LEDs. However, larger LEDs can draw 1W-3W, which limits the number of such LEDs you can drive with a ULN2003 to less than 5.

Remember, the OP gave no indication re: the power of his LED string...

PWM at any speed is not good with relays. The contacts are usually rated for so many closures, which PWM would quickly wear out, and the chattering would drive one mad as well.

Im just trying to get my head around the wiring for the transistors. I figure id need NPN type for the low-side switching.

How does this look? http://i.imgur.com/BE7jniN.gif

Base +5v (arduino pwm output)
Collector -12v (led strip negative)
Emitter -12v (led strip negative)

Sorry if this is elementary stuff, im a bit new to electronics

(edit: the led strips are http://j.mp/YmLEuX I will use about 30 low power leds (50cm) and should have a draw about 200ma )

Use the example on pin D12. Emitter connects to Arduino Gnd and to power supply Gnd.
LED strip+ goes to 12V, LED strip- goes to the collector.

CrossRoads:
Use the example on pin D12. Emitter connects to Arduino Gnd and to power supply Gnd.
LED strip+ goes to 12V, LED strip- goes to the collector.

perfect thanks :slight_smile:

Can I ask why the arduino and 12v grounds are tied together, I don't quite understand how that works

All signals need to have a common reference point. Gnd provides that.

CrossRoads:
PWM at any speed is not good with relays. The contacts are usually rated for so many closures, which PWM would quickly wear out, and the chattering would drive one mad as well.

Crossroads, thank you for the help but please allow me to quibble re: the above. Many appliances feature relays being used in a PWM manner. Whether its cooktops, ovens, clothes dryers, or microwave ovens, large loads are still predominantly switched using relays in the white goods industry. However, that's not to say that Triacs and similar solid state devices that allow faster PWM without the chatter you describe are not used, far from it.

The electric cooktops of a client of mine started using solid state switching devices in 1999, there is a Triac for suction control in our Kenmore canister vacuum cleaner, and variable-speed drives are also quite common for motors / compressors in clothes washers, dishwashers, mini-split AC systems, and even refrigerators.

These days its not uncommon to find appliances that feature both solid state as well as electro-mechanical switching systems. Some things like LEDs get dedicated LED driver chips to enable dimming, multi-color displays, etc. while larger loads that do not require speed control still predominantly use relays. Some appliances like microwave may feature a couple of small Triacs for small loads in addition to larger electro-mechanical relays for the magnetron power supply and other loads.

I expect more and more solid state relays being used in appliances as time goes on, driven by the dropping costs for solid state options and the features that can be added to appliances through their use. Years ago, a variable-speed motor in a vacuum cleaner would have been realized with multiple speed taps and a bank of relays or a high-power selecting switch, today it's done some pushbuttons, a Attiny, and one Triac. The soaring cost of commodities (such as the additional power lines required for the old approach) vs. the dropping costs of and greater familiarity with solid state devices presumably had something to do with that.

Thus, both types of power switching technologies currently find their application in high- and low-power switching situations, with and without PWM. As I see it, the most applicable solution depends on many factors and it wasn't clear to me just what the application was going to be, i.e. the magnitude of the load being switched, the speed requirements / duty cycle for the PWM, etc. Thanks again for all you do for the community!

"But im going to want to replace these leds with led strips that run on 12v, but the attiny runs 5v and so are it's outputs."

Constantin, you can quibble all you want to, I'm always up for a good argument 8)

The goal above says to me "switch with a transistor", reinforced by the picture of a few LEDs being directly controlled. Nothing that needed complication with relays.
Especially when a single chip like ULN2003 could do all 4 channels. 4 Relays would need a lot more room, and typically need more drive current to turn each relay on & then hold it on.
The later statement saying PWM was planned also enforced that.

Solid State Relay = transistor!