Transistor issues or: why does this work?

Hello everyone, I'm getting a little confused here, so I hoped there's someone around who can point me to my fault..

I built a circuit that looks somewhat like this: (although i have a total of 4 transistors/LEDs)
The transistor is a 2N3904, the LEDs are standard 3.5V/30mA.
[the board is telling me I can't post images before having posted 1 normal message, so see next post for image :wink: ]

The code I'm currently running basically says something like
analogWrite(10, 64);
analogWrite(11, 64);

Works fine so far, but there's something bugging me: I'm pretty new to transistors but I thought I had read enough to know that they are for seperating two currents from each other.
Now when I disconnect one of the emitters from the 9V's ground (basically pulling out one of the 47Rs) its LEDs still remain bright.
It's making me anxious because that would mean that the whole 90mA are floating into the Arduino's ground, which is exactly what I wanted to avoid by using a transistor.. What am I missing? I always thought that if the collector-emitter-path is not closed then there won't be any current flowing? If anyone could point this out for me I'd be incredibly thankful!

Second question: I'm currently powering the right part of the circuit with a 9V block (the arduino should be getting its power from the usb port). I heard that 9Vs are not good for high currents, but I actually wanted to add a lot more LEDs (maybe 6 or more of those blocks, that would make > 540mA)
Any suggestions what would be a better power supply? I want to stitch the whole thing onto a piece of clothing, so any ideas on that would be greatly appreaciated, too!

Thanks a lot in advance! I guess things are beginning to get too complex for me..

vallee

seperating two currents from each other

Transistors AMPLIFY a current, ie you put 1 into the base and 100 flow from C to E (depending on the gain of the transistor).

I'm guessing your LEDs are grounded through the 22R resistors even if you think the GNDs are seperate I suspect they are connected through the power supplies, connected computer or something. If the 9v is indeed totally isolated then it doesn't make sense.

Anyway remove the 22Rs (or are they 2R2s) entirely (not sure why they are there) and connect the Arduino GND directly to the 9v GND.

You're right about the 9v battery current abilities, but I can't think of anything better if you're stitching the circuit into clothes.

Thinking...

You don't really need 9v, more like 4.5-5 so what about a 6v battery? They are available in various current capabilities.

Oops, just noticed, you must have a resistor from the Arduino pin to the transistor bases, otherwise the pins are effectively trying to drive a diode to ground.

Also move the 47Rs (is that right, seems a little low?) above the transistors.

I was going to try some ASCII art but am hopeless at it, so here's how this sort of thing is usually done.

Hello Graynomad, thanks for the quick reply!

you must have a resistor from the Arduino pin to the transistor bases

actually, thats what i was thinking with the 2.2Rs... just at the wrong place :wink:
i just followed your advice and changed the whole thing and it works fine now!

but what i think the initial problem really was is the PWM signal. i guess whenever the signal was off the current from the "unconnected" emitter would flow all the way through the two 2.2Rs, the other 47R to the 9Vs ground... does that make sense? at least that would also explain the brief flickering of the LEDs i thought wasn't worth mentioning...

man that whole PWM thing has messed with my brain times before! i thought i should know by now :wink:

thanks again! you made my day :slight_smile:

flow all the way through the two 2.2Rs, the other 47R to the 9Vs ground

Yep I didn't spot that, I'd say you're right.

BTW, the base resistors would normally be a fairly high value, say 10k. LED current resistors are usually 330/470R sort of values but of course depends on the voltage and current.

I don't know much about Arduinos so when you said PWM I had to research the analogWrite command, hmmm, why on earth would a PWM command be called analogWrite. Yes I know PWM can be used to generate analog voltages with external circuitry, but that's not what the command is actually doing, it's generating a PWM square wave.

analogRead doesn't read a frequency does it?

Just one of life's mysteries I suppose. :slight_smile:

Remember... Arduino is for non-geeks too. Pulse Width Modulation (PWM) is not an everyday combination of words... "Analog Write" is. ... and it starts make more sense when you combine it with AnalogRead(). PWM makes no sense for input... but making the the two commands AnalogRead AnalogWrite related to each other... does make sense.

why on earth would a PWM command be called analogWrite

Indeed the original thought was it would be easier for non-technical beginners to understand and use. Many of us consider it a 'brain fart' of a name but as time passed on we are kind of stuck with it. :wink:

Yeah I understand that we often get saddled with historical stuff and in context it does make some sense for the non-nerd audience. Anyway I'm not having a go at Arduino, it's a great concept (rather like Picaxe but more powerful) and just the thing for quick prototyping, one-off designs, or people getting into micros.

Anyway I'm not having a go at Arduino

Good choice. The fact that it's both hardware and software open sourced and multi-platform makes it pretty unique from any prior offering that I had come across. This then has lead to a hugh 3rd party vendor support base and of course a hugh and still growing user base that has contributed so many software libraries.

I started with Picaxe because of the small inital start-up cost and friendly user forum, but the power of C/C++ along with a free user friendly IDE makes it a winner in my book.