Electronic – arduino – Switching a 3V led series with an Arduino uno with 5V supply

arduinoswitchestransistors

just to verify my idea. I'd like to switch on and off a series of led supplied with 2 AA batteries with an Arduino uno.
I'd like to use an 2N3904 transistor.
The collector of the transistor will be connected to the series of leds and to the 3V led voltage supply, the base will be connected to an arduino GPIO trough a resistor. The emitter will be connected to ground. Is this a good schema?

schematic

simulate this circuit – Schematic created using CircuitLab

Thanks,
Giuseppe

Best Answer

This is almost a reasonable circuit. You need to add a resistor in series with the LED. This is necessary to limit the LED current.

Let's say this is a green LED that can handle up to 20 mA. The LED drops 2.1 V, and let's say the transistor will have 200 mV across it when on. That leaves 700 mV for the resistor to drop. (700 mV)/(20 mA) = 35 Ω. You could use the standard value of 36 Ω, and theoretically be right on the edge. However, the "3 V" battery is probably a little more, and you want some margin to make sure the LED is operated within spec. The next higher up common value of 39 Ω or even 43 Ω would be better, unless you absolutely need every last bit of light for some reason.

You also haven't specified R1. Again, let's say the aim is to support up to 20 mA LED current. We want the transistor to be saturated, so let's say we decide the base voltage using a C/B current ratio of 20, knowing this transistor can be counted on to have more gain than that. That means we want a minimum base current of 1 mA when on. If the B-E junction drops 700 mV, then 4.3 V will be across the resistor.

(4.3 V)/(1 mA) = 4.3 kΩ. That's the maximum allowed value from our calculations. 4.3 kΩ is a standard value. You could use that, since we've built in some slop into the calculations. Or, use whatever next convenient value you have below that. The limiting factor is how much current the microcontroller output can source, which is likely a few mA. You therefore have a rather wide latitude with R1.