Electronic – arduino – Calculating the resistance for the base of a transistor

arduinoledschematicstransistors

I'm building a circuit for my little niece's birthday (I'm already overdue with a couple of days).
I started building it before I well understood enough about transistors and no I'm running a little out of time.

The whole project (it's actually a small city, build with recycled parts, in which I placed a lot of LEDS) is nearly finished, what's left are putting the resistors R10 – R19 in place.
If somebody could take a look at the picture and tell me how I should calculate the value of these resistors ?

Also, Can I power the arduino (5v) with the same power source (12v) using only resistors, or should I use a step down convertor (or build one) ?

LED Circuit

I think I'm going to choose this adapter instead of the one I was previously talking about. It was previously used for a USB Hard disk and supplies both 12v and 5v. It probably has a regulator built-in ?
How do I know ?

enter image description here

Best Answer

Any serious processing device like an arduino should be provided with as stable a voltage as you can provide it, so resistive regulation will likely not be adequate. I'd recommend a 5v DC switching regulator rated for 2A(although someone who uses arduinos may have a better reccomendation) as long as your 12V supply can support both it and the LEDs. That way you can keep the 120V entirely away from the childrens toy. If you have a multimeter, it would be wise to meter the no load output of your 12V supply. Once you've confirmed your 12V supply is good for it, you can look for a "2A 5V switching regulator" and now that you know your min and max voltage, you can find a regulator that is good over that voltage range.

As far as sizing all of those resistors, you have two types of resistors to size. The ones in series with the LEDs prevent thermal runaway when current regulation is not being used. You can look up or check the LED's rated voltage at the current you want to flow, and then you can size based on the following principle:

\$12V = V_{LED}+I_{LED}*R\$

Plug in the values and solve for R. So if you had an LED rated for 2.4V@15mA,

\$12V = 2.4V+15mA*R\$

\$9.6V = .015A*R\$

\$R = 640\Omega\$

As for your transistor base resistors, if you know the gain of your transistor, divide the current you want to flow by the gain and you will have your desired base current. Then solve \$R = E/I\$, where E is the gate voltage and I is the gate current, to find the value of the needed resistor.

There is probably a better way to do this, but this is simple and has been adequate for me. If you have a potentiometer or other variable resistor, you can also attach it to the base where the base resistor would be, vary it to an acceptable current, then detach it, meter it and replace it with the next larger size resistor available.