ok, so i built a circuit now that pretty much "works". So basically i built a circuit just like in the picture only with a bunch more of those transistors connected to leds. The problem is that whenever i switch more than two of those transistors thus lighting my led's my arduino get's really hot. I then tried a lot of different base resistors for my transistors ranging from 1k to all the way up to 1m. With all of those transistors my led's just light up fine, which leads me to believe i still need to increase the base resistor?
However 1m seems already quite high so there might be a totally different problem?
some data that may help:
transistor type :2N2222
external power supply : 12v 3A
Using a 9v 1A power supply to power the Arduino
Do you have a resistor between the Arduino IO pin and the transistor base pin? If not, you are basically asking the pin to drive a diode to Gnd. The resistor limits the current.
(5V - 0.7V)/..02a A = 215 ohm, so a 220, 270 would work well.
Ok so I tried it with a 220 ohm resistor between the base and the io pin now. But it is still giving me the same results. When I have two resistors on the heat seems to be ok. But once I light up the third string of LEDs the Arduino becomes really hot in a matter of second's...
It should not get hot at all. I think you wired something wrong, not like in your diagram. Post some well-lit, well-focussed close-up pics and make sure the wiring is neat and we can see where every wire is connected.
Heh! Easy enough for you Paul living in Oz... Don't know where the OP is but here in the UK it is sunny this morning but literally freezing, and this is the first time in a week. Until now it has been raining heavily with occasional periods of fog and drizzle under leaden grey skies!
Ok I got a few pictures now, I hope they are well lit and easy enough to see where all the wires go because I think it is kind of hard to tell from the pictures.
Also, in this current configuration it doesn't get really hot just a little bit. Once I add more LEDs with transistors like I did there it gets pretty hot rather quickly.
Ok, I see the problem. Your base resistors are being shorted by the breadboard. They are doing nothing and a very large current is flowing from the Arduino pins to ground through the transistor base, hence the overheating and the fact that it made no difference what value of resistor you were using. You need to remember how breadboards are connected behind the holes and wire things up appropriately.
Looking back at your fritzing diagram, you made the same mistake and we did not spot it, sorry.
Oh, I yes you are totally right. I don't know why I didn't see that myself, I feel kind of stupid now for not seeing that :
Thanks for pointing that out.
Once you have fixed the wiring of the base resistors, you will discover that 100K is much too high, and the transistors will not switch on. Between 220R and 4K7 will probably work.
To work out the ideal resistor value, you need to read the data sheet of the transistor to find out the "gain" of the transistor under the conditions you are using it in. But let's say the gain is 60 to make the maths easy. Your groups of LEDs probably draw around 60mA (20mA for each group of 3 LEDs in series). To switch the transistor on, you only need 1mA to follow into the base to allow 60mA to follow into the collector, because the gain is 60. That's the minimum current you need, so maybe allow 2mA to ensure the transistor is fully "saturated", minimising it's voltage drop so it stays cool and your LEDs are bright. For 2mA base current, the resistor should be around 5 / 0.002 = 2.5K, so 2K2 would be ok (that's assuming gain really is 60).
Try the 4K7. Measure the voltage drop across the collector & emitter. Then swap to the 1K and measure again. If the difference is small (<0.1V) then the 4K7 is enough to saturate the transistor. Don't use analogWrite() for this measurement, use digitalWrite(pin, HIGH).
However, if you later add more LEDs to the same transistor, that will change the gain a little, and so change the base current required, so repeat the test again.