How to use a transistor to drive strings of LEDs from GPIO pins?
You have wimpy GPIO.  You want 250mA, and you want (trust me on this) to saturate your output transistor.  A 2N4401 needs a base current to collector current ratio of 1:10 in saturation.  So you need 25mA at the base of your output transistor.  This is more than your wimpy GPIO supplies.  So you need another transistor.

Q1 is an emitter follower.  It's emitter voltage will be 0V when the GPIO pin is low, and 0.7V below the GPIO pin voltage when the pin is high.  Assuming that the supply voltage to the microprocessor is 5V, the base of Q1 will be 4.3V when the GPIO pin is high.  The base of Q2 will be at about 0.7V when Q2 is on.  This leaves 3.6V to generate current across R1.

You need 30mA at R1 (that's 25mA rounded up).  (3.6V)/(30mA) = 120\$\Omega\$ (note that the units work out -- it's nice when that happens).  As long as your Arduino is a 5V unit, you're fine.  Change R1 to 47\$\Omega\$ if it's a 3.3V one.

LEDs do not like to be driven from a voltage source -- you need to start with the voltage you're supplying, and work out how to give them the specified current.  Your LEDs drop around 3.5V (check that, I'm going from memory and I'm lazy).  Assuming you're driving this string from a 9V source, you can run pairs in series with one current-limit resistor -- that's the R2 I'm showing in the diagram.

If you have \$N\$ LEDs in a string (two if it's 9V, one if it's 5V), then $$ R_2 = \frac{V_{cc} - N V_{led}}{I_{led}} $$  In the case that you use 9V and you want 20mA, that's R = (9V - 2 * 3.5V) / (20mA) = (2V) / (20mA) = 100\$\Omega\$.

Note that you probably don't want to get your 9V from a "9V" battery.  A "9V" battery is 9V, fully charged with a light load, and you don't want to pull more than about 50mA from it.  If you are going to pull 250mA (or even 125mA), then you should design your circuit to still work at around 6V -- which means just one LED per section, which means twice the current, you can't win for losing, etc.

So -- use a 9V wall-wart and be happy.







simulate this circuit &ndash; Schematic created using CircuitLab