# Controlling voltage and current from chip?

I'm well aware that this question perfectly showcases my spectacular ignorance, but oh well. It's a simple enough question, so here we go.

I have a 595 chip (SN74HC595) wired up to an Arduino, fed by the 5V output. After switching all the outputs on, I measured an output pin at 5.04V and 74mA.

I want to use the chip's outputs to switch transistors (P2N2222A) which will have 60 mA through them (switching common cathode RGB LEDs), so I believe I need to drop it down to around .6 to 1.2V at .6mA, right (I'm not at all sure I'm reading the datasheet right)?

So how exactly do I do that? It seems like I need to put a resistor in between the pin and the base, but don't I need to know the TOTAL resistance of the circuit? Or can I just calculate from the pin itself (I believe that would need 7K)?

EDIT:

EDIT 2: Resistor values are listed wrong. R1=200, R2 & R3 = 100.

• 74mA was your total draw (including arduino?) I am very confused what your trying to do here. Please provide a schematic showing what you have/ what you intend on doing. I am fairly certain your assumptions about the 1.2V/.6mA thing is wrong, but not sure exactly what your talking about yet – Chad G Apr 26 '18 at 21:14
• Added hurriedly thrown together schematic. – Don Apr 26 '18 at 21:58
• You dont need the transistors or the IC to turn on those two LED's. Right now, both LED's will be the same(is that what you want) but you can just connect them to ground(remove transistors and IC) and then control their colors via the pins(6,5,4). Also no sure why you have different value resistors for each color, the 100, and 200 ohm ones are too low. I would suggest at least 680ohm, but the 1k should be fine too – Chad G Apr 26 '18 at 22:09
• Connecting an ammeter between a pin and ground is silly. That's just like shorting the pin to ground, and will show the maximum the chip is capable of, which is usually far more than it's rated for. – Majenko Apr 26 '18 at 22:21
• @ChadG, the transistors are there so that I can expand the circuit beyond two LEDs. I realize I could simply drive two LEDs directly from the board's PWM pins, but there are only 6 of those, limiting me to two LEDs. This way I can switch them on one at a time fast enough that they appear to remain lit. I did mess up the resistor values, but they should be 200, 100, and 100. The red part of the LED drops 2V and needs 20mA, so (5-2)/.02=150, rounding up to the nearest resistor value I have. The blue and green drop 3.2V, so (5-3.2)/.02=90, rounding up to the nearest resistor I have. – Don Apr 26 '18 at 23:55

You're misunderstanding what you need to drive a transistor.

A transistor will allow up to a specific amount of current through the collector depending on the current that flows through the base. If less is needed by the load then less will flow.

Think of it like a tap. If there's not much water pressure it doesn't matter how far you turn on the tap, after a certain point the flow of water won't increase any more.

To allow 60mA through the collector you need to provide at least 0.6mA (assuming a hFE of 100) through the base. That 0.6mA will set the upper limit of the current to 60mA. If you provide more than 0.6mA then you will allow a higher upper limit.

The 0.6V on the base is the voltage (difference between base and emitter when wired as "common emitter") at which current will start flowing through the base. It's the same concept as the forward voltage of an LED. For switching the voltage you put on the base must be more than 0.6V to allow current to start flowing. Since 5V is more than 0.6V you don't need to worry about it. If you want precision in your calculations you will want to take that 0.6V into account, though.

So if you want at least 0.6mA from 5V with a 0.6V drop on the BE junction, you need:

R=V/I = (5 - 0.6) / 0.0006 = 7.3kΩ.


That's the maximum resistance you want. Anything more than that and the current through the base will limit the current through the collector to below the 60mA you want. So you must select some resistance that is lower than that.

What value? Well, it really doesn't matter that much. The lower the value the higher the current, but at these levels the current levels you're dealing with will be minuscule anyway.

It's common to use a 1kΩ resistor in the base for a transistor when using it as a simple switch like you are. That would give you, for each transistor:

I=V/R = (5 - 0.6) / 1000 = 4.4mA


For all 8 outputs that's a paltry 35.2mA. Far below the total the chip can provide of 70mA.

If you care about current consumption (you're running from batteries, for instance) you may want to increase to 4.7kΩ resistors to reduce the total drive current down to 7.5mA.

• Thank you for such an in-depth explanation. I'm trying to make sure I've wrapped my head around this. I'll try out some of your examples tomorrow. Will putting the ammeter across the resistor give me the correct current? – Don Apr 26 '18 at 23:58
• Ammeters go in series with the connection, not parallel. – Majenko Apr 27 '18 at 0:00
• So in terms of calculating the voltage and current, I treat the pin as a 5V DC source? – Don Apr 27 '18 at 8:51
• Well, that's what it it... – Majenko Apr 27 '18 at 8:52
• Thanks again for the great explanation. Tried it out with some 2K and 5K resistors (making sure to put the meter in SERIES for current measurements this time), checking against the math, and I see what you're saying. :D – Don Apr 27 '18 at 13:22

You are making the design more complicated than it needs to be. Use a WS2803 chip, it has 18 outputs, 0-255 PWM level programmable for each output. Got more LEDs? Use more chips. http://da-share.com/files/datasheets/WS2803.pdf

Or use WS2812B RGB LEDs, easy to wire up in a daisychain. SMD typically, and Sparkfun carries 2 thru hole variants also.

• Thanks for the tip, but I'm aware that this isn't the optimal or easy way to do this. I've actually already ordered some PWM expansion chips (TLC5940), but they haven't arrived yet, and won't for about a month. So I'm trying to figure out how to do it with what I have on hand, and what I have on hand is a dozen or so 595s. Besides, I'm learning more this way. :D – Don Apr 27 '18 at 13:40
• Where did you order from? Digikey.com or Mouser.com would have had them to you in under a week in the US. – CrossRoads Apr 27 '18 at 14:36
• Chinese crap off ebay. I know, "boo, hiss". And I know there's a good chance of them not being authentic or good quality, but I'm just tinkering around on my kitchen table here, so... Also, I am not in the U.S. – Don Apr 27 '18 at 15:52