Go Down

Topic: Using 5v To switch 12v supply? (ATtiny in car use) (Read 5747 times) previous topic - next topic

Hi guys, This is a tricky one that has me confused!

Basically I have used my arduino to program a little ATtiny85 that turns On/off Supply to a pin (LED's to be attached) With the function of being able to adjust the brightness by holding the button down (As explained in getting started with arduino book example 5).

I have it all working to the stage where I can turn on and off and vary brightness of some 3v led's without the use of resistors, BUT I designed the circuit for use in my car where I wanted to use 12v LED strips. The input voltage for the ATtiny is 3.2 - 5.5 V so I will have to use a voltage regulator to limit that (I forgot how to do this exactly to what I need! :P) . The problem arises where I am not sure if it is possible to effectively Upscale the voltage from the pin to 12v (Whilst still being able to adjust voltage to vary brightness) Or to use the ATtiny's output to effectively switch on and alter the 12v supply seperately.
I think it may be possible with some kind of transistor but this one truly has me confused!

That probably sounded like a load of nonsense so I professionally made up a BS8888 Standard Engineeirng drawing for you below ;) (The wonders of paint! :P)

I would greatly appreciate any help you could give me... I'm truly stuck! :D

Thankyou and happy modding!

EDIT: I just noticed I forgot to connect the other pin of the Button to the +VCC on my expert diagram hahaha, assume it is connected :P

First off, you should never be using an component LED without a resistor.

Yes, you can use a transistor to switch on and off the LED strip, but the strip would still be powered of the 12V, not the 5V supply of the MCU.  The specific transistor and how to bias it would depend on the current the LED strip draws.  So you need the specs of the particular LED strip.

For your regulator dilemma, look up the datasheet for a LM78L05.
Facts just don't care if you ignore them.


You also need capacitors across the input and output of the regulator, that middle pin goes to ground.

Thanks for the replies,
The Forward Voltage is 12v
The Forward Current 20mA
More info here : http://www.phenoptix.com/index.php/led-tape/blue-12v-led-strip-5cm-smd-leds-flexible-tape.html
I believe That If I use an LM317 Voltage Regulator with Resistor values of R1= 330 Ohms And R2 = 1kOhm I can get a moderately accurate 5.04v Supply to the ATtiny.

As for the transistor, I'm still confused But I have been told I can use an NPN 2N3904 General Purpose tranistor with specific resistors to do this, not entirely sure how though as I effectively need two inputs (12v Supply for the LED Strips, and 0 - 5V Variable supply from the ATTiny ouput pin) with one output to the LED's that varies relatively to the ATTiny.
I know this is possible due to a transistor obviously being and acting as a transforming resistor; effectively raising the voltage but keeping the proportions.. A bit more help would be appreciated! :D

And as for the Resistors on the LED's, the 12v Strips I am using have built in SMD resistors.


Driving an LED strip is just like driving a motor, or a relay. Look at the first two circuits here:-

If I use an LM317 Voltage Regulator

But if you used a fixed voltage regulator then you would not have to bother. There are hundreds to choose from here:-

effectively raising the voltage but keeping the proportions

No that is not how transistors work, see:-

and 0 - 5V Variable supply from the ATTiny ouput pin)

No you don't which is just as well as you can't get such a thing. Do you want to dim the LEDs?
If so they might respond to a PWM output, this is not a variable voltage output but a digital signal:-

Have a look at the attached schematic.  This should work for you.
Facts just don't care if you ignore them.

Hey guys, Thanks for all the help...
BillO that looks like a KI cad shcematic!? :P
I was hoping to get a couple of mini pcb's produced to make the finish more professional and tidy, I was wandering if you could send me the KI cad files for that schematic so I can convert it to a PCB layout?
That would be awesome! :D
I have just ordered the specific components you stated, so I'll breadboard a circuit when I get them in the post and If it all works I'll send off for a pcb or two! (I could send you one if you like, as a thankyou for helping?)
Anyway... let me know! :D

It was drawn with DipTrace, but I only retained in JPEG form, sorry.  It should take not take much time to enter it into some other application though.

If you're stuck and can wait till next week I can re-do it and even do a lay-out and produce the Gerber files.  But I'm pretty busy until next Monday.
Facts just don't care if you ignore them.

Finally got the last of the components for this today, and I just built a breadboard circuit. It works... BUT It's working as if it's reading the reverse of the button, eg it thinks its being pressed when its not, and when its not being pressed it thinks it is!
Because I have it set to a momentary press to turn on/off, that bit is not affected due to a simple state change in the program, But what it does is it stays on and changes brightness as if you are holding the button! :S I think I have wired it up correctly... Here's a photo of my breadboard circuit... Can you spot anything i've done wrong? I have double checked! :L
And as regards to the circuit schematic, thanks for the offer that is very kind of you, but i'll have an attempt at it in KiCad then post it here for you guys to double check :P

Cheers again,

If I were you I'd ditch the transistor and use a relay. Relays are simpler to wire, they already come made for auto use, and they generally can handle more current than a transistor. That is unless you are looking to dim the leds with pwm, because relays aren't that fast at switching.

You'd need a transistor to drive the relay, so no, do not ditch the transistor.  It's just fine.

In this circuit, the input at pin2 goes low when the button is pressed, and from what I can see that looks correct.  Does the code expect the input to be active low or high?
Facts just don't care if you ignore them.

You'd need a transistor to drive the relay, so no, do not ditch the transistor.  It's just fine.

In this circuit, the input at pin2 goes low when the button is pressed, and from what I can see that looks correct.  Does the code expect the input to be active low or high?

Right, The code waits for the button input to be high, so I think that's where the problem could be... I can paste the code if you need?
And I really appreciate your help on this by the way! :D

Facts just don't care if you ignore them.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131