Arduino Forum upgrade scheduled for Monday, October 20th, 11am-4pm (CEST). Sorry for the inconvenience!
Pages: [1]   Go Down
Author Topic: Beginners question about resistors, transistors & current output on the Uno  (Read 582 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 362
Posts: 17320
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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
« Last Edit: December 02, 2012, 11:20:17 am by retrolefty » Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 654
Posts: 35023
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

0
Offline Offline
Edison Member
*
Karma: 8
Posts: 1251
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

lefty-

nice explanation!!

Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...)?
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 362
Posts: 17320
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 555
Posts: 27683
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.


* Driving_LEDs.jpg (51.09 KB, 960x720 - viewed 15 times.)
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Pages: [1]   Go Up
Arduino Forum upgrade scheduled for Monday, October 20th, 11am-4pm (CEST). Sorry for the inconvenience!
Jump to: