I need to calculate resistor for a PNP transistor.
To do this I need to know the voltage and current.
I know voltage is 5 volts as it is easy to find in the internet, but how about current? I mean people say the maximum current is 40 mA, but will it be 40mA? Does the arduino supply 40mA as long as it is able to? Or for example if i just connect a single diode it magically "calculates" the current it needs and supplies, let's say, 20mA?

  • voltage depends on source, current depends on load. too much current and the voltage goes down. – dandavis Mar 27 '18 at 19:32
  • Electronics doesn't use magic. – Nick Gammon Apr 2 '18 at 7:45
  • Which resistor? Base or load? – Nick Gammon Apr 2 '18 at 7:46

It means that a pin can give (source) at max. 40 mA. However, if a components uses more, than the Arduino cannot give it and as a result the pin becomes unusable.

So you never should exceed 40 mA. And 20 mA is adviced.

+5V and GND pins can take more, however there is also a maximum on 'groups' of GPIO pins. See more information here, below is an excerpt of the page.

However, I doubt that your transistor needs so much, most (if not all) are directly controllable from a GPIO pin and if you need to calculate a resistor value, just make sure you are safely above the minimum current needed to switch the transistor.

enter image description here

| improve this answer | |
  • 1
    That's a great diagram and captures 1/2 of the Notes under the table in section 30 well - there is another section on Sink currents. To reach the full 300mA of sink or source current, a Surface Mount 328P needs to be used; the 328P in DIP only provide One VCC and One Gnd pin, and the chips have a max limit of 200mA per per pin, which I have personally confirmed with Atmel Tech Support. Datasheet can be downloaded here <microchip.com/wwwproducts/en/atmega328p> – CrossRoads Apr 3 '18 at 14:54

Figure on driving the PNP hard so it turns in into full saturation. To do that, you want to pull as much current from the base as you can. Treat the PNP like it is one diode drop of voltage away from 5V when on. So 4.3V generally (maybe 4.5, check your part specs). Then you want the Arduino to sink 20 mA. 4.3V/20mA = 215 ohm resistor. Use a 200, 220, both are standard values and should well to protect the Arduino output transistors and drive the PNP into saturation. Maybe go as low as 150 ohm to drive a little harder. If the PNP needs less to turn on full, go a little higher resistance value.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.