Beginners question about resistors, transistors & current output on the Uno

Hello,

I have a couple of general questions about resistors, transistors and the maximum output of current on the Uno. Please forgive for asking about such rudimentary things, however I have absolutely no previous experience of electrical engineering.

In most beginners tutorials the first thing you learn is to flash a led. In almost all of these tutorials a resistor of some size is used to restrict the flow of current. However the output of current for each pin on the Uno is as far as I am aware 40 mA. So if I have a led that is rated at for example 150 mA this means that I will not burn the led even I do not use a resistor, right?

Second, if I would like to flash the led as bright as possible I believe I need to use a transistor, however I am not quite sure what the correct setup is. I think I should connect the base to the output pin on the Uno, the collector to the positive side of my external source (9V battery) and the emitter to the led, however I am not sure where to go after that. Should I connect the other pin of the led (i.e. the pin that is not collected to the emitter) to the ground of the Uno or to the ground of the external source. Also in order not to burn the led I guess I need to use at least a (9-1,5)/0,150= 50 ohm resistor (the forward voltage of the led is 1,5), right? Further, can I use a resistor in between the output on the Uno and the base of the transistor in order to decrease the battery drain of the Uno?

Third, how come the output of current is only 40 mA on the Uno?

Best regards,
Rocket

Third, how come the output of current is only 40 mA on the Uno?

As a begineer to electronics you really should study a tutorial on basic Ohm's Law fundamentals as that will explain the relationship of voltage, current, and resistance in a DC circuit.

But to try and answers your above question an arduino output pin is a simple voltage source outputting +5vdc when set to a HIGH output. How much current that is drawn from the pin is only a function of the resistance of the external circuit wired to the output pin. So a Uno output pin can't 'force' any specific amount of current out it's pin, that is a function of what the load resistance of what is wired to the pin is trying to draw from the pin. The 40ma rating for an output pin is just a safety warning that if you try and draw that much or more you will damage the output pin, as the output pin cannot limit the current to 40ma or less, only the external circuitry can do that. That may still not be clear, so that is why I suggest you read a ohms law lesson.

So the formula to calculate current flow in a simple DC circuit is I (current in amps) = E (voltage in volts) / R (resistance in ohms). The E for an arduino output pin is fixed to +5vdc if set high, so the amount of R in a circuit is the only thing that will determine the amount of I that will flow. And if R is too low such that I is 40ma or more the output pin can be damaged.

Lefty

on the Uno, the collector to the positive side of my external source (9V battery) and the emitter to the led

No this is not the right setup. The output of the arduino goes to a resistor, make it 1K, the other end of the resistor to the base. The emitter goes to ground and your load of Laead and resistor is wired between the collector and +5V.
You need the base resistor to protect your arduino output pin like Lefty said, and to limit its current to a safe value.

lefty-

nice explanation!!

Hi Lefty and you others,

Thanks for explaining this to me. I actually had had a look at ohm's law and that was kind of the reason for my last question. I basically could not figure out how 5V/0R=40mA (OK if you would use a wire to hook up the output pin straight to ground I guess the wire would add some resistance....). Anyway, now that I understand that 40mA is the highest SAFE output, and not the absolute maximum, this is much clearer to me.

Also, my first thought when reading Lefty's reply was that I MUST put a resistor between the output and the base not to burn the output pin on the Uno, and this was of course confirmed by Grumpy_Mike. However, I am not quite sure of the rest... Do you mean that I should wire a "suitable" resistor to the collector, and then wire the led to the resistor, and the wire the led to the 5V power source on the Uno (yes, why should I use a external 9V battery when the on board 5V is enough, silly me...)? Further, I guess that a "suitable" resistor in this case would be at least (5-1,5)/0,150= 23ohm (maybe 30 ohm just to be safe...)?

Also, my first thought when reading Lefty's reply was that I MUST put a resistor between the output and the base not to burn the output pin on the Uno, and this was of course confirmed by Grumpy_Mike. However, I am not quite sure of the rest... Do you mean that I should wire a "suitable" resistor to the collector, and then wire the led to the resistor, and the wire the led to the 5V power source on the Uno (yes, why should I use a external 9V battery when the on board 5V is enough, silly me...)? Further, I guess that a "suitable" resistor in this case would be at least (5-1,5)/0,150= 23ohm (maybe 30 ohm just to be safe...)?

Yes, the resistor from the arduino pin to the base will protect the output pin, but if there is not resistor on the collector circuit then there is nothing to limit the current flowing through the led and collector/emitter circuit to ground and damaging both the transistor and led, so it too needs a resistor to set the current flow to 150ma or whatever amount the LED requires. The choice of using the arduino 5V pin or an external 9 volt source is up to you but it will effect the calculation for proper sizing of the collector resistor.

Lefty

Maybe this will help, showing the different ways to connect up LEDs from the 5V header on the Arduino.
If you have current going thru the LED, there will be battery drain whether the LED is controlled by an internal transisor or an external transistor.

Hi all,

Ok, so basically I understood Grumpy_Mike's reply about the the transistor/resistor/led circuit in the right way.

Of to some testing.
Cheers!