I am developing a system wich includes a laser-pointer and a digital LDR module. I'd like to switch the lasers with the GPIO pins on the raspberry. But, since I'm used to working with Arduino's and was not aware that the Raspberry has an 3.3V GPIO output, I bought lasers that ideally work with 5V power supply. It is necessary to turn the lasers on and off so the regular 5V output is not an option. So I thought using a transistor as a switch would be the answer.

My question in short: I have been looking at datasheets of different transistors but I'm not able to figure out what the switching voltage is called.

Does anyone know about a transistor type that can switch 5V power with an 3.3V switching voltage?

  • 1
    \$\begingroup\$ I don't think the Pi is at all relevant to the question. Any general purpose transistor should do what you want, e.g. see hobbytronics.co.uk/electronic-components/transistors for the BC548B and BC212L. \$\endgroup\$
    – joan
    Jun 13, 2016 at 11:07
  • \$\begingroup\$ Since it sounds like there are multiple such connections, and it is a one way relationship (i.e., you do not have to also shift a 5V input to 3.3V) you might consider an IC with a Darlington array in it -- I think the ULN2xxx series is the most commonplace. These are very inexpensive and available many place online. \$\endgroup\$
    – fizzle
    Jun 13, 2016 at 11:18
  • 2
    \$\begingroup\$ Directly driving the laser (whether from an Ardunio or a Pi) would have been a bad idea anyway. You can either use a bipolar transistor, or a MOSFET \$\endgroup\$
    – JRE
    Jun 13, 2016 at 11:37
  • \$\begingroup\$ Also electronics.stackexchange.com/questions/81135/… \$\endgroup\$
    – dim
    Jun 13, 2016 at 12:03
  • 2
    \$\begingroup\$ ...etc. Now, if you're stuck at figuring out the "switching voltage" of a NPN transistor, that is because a NPN does not really have a switching voltage. You need to make current flow from the base to the emitter (using a resistor between the GPIO and the base). A MOSFET, however, has a switching voltage, called threshold voltage. \$\endgroup\$
    – dim
    Jun 13, 2016 at 12:07

1 Answer 1


I'll answer the more general question of how to switch a load on/off from a digital signal when the load requires current or voltage that the digital signal can't supply directly.

One very common and cheap way is to use a NPN load side switch:

R1 must be sized so that the maximum current the digital output can source when high is not exceeded. For example, let's say that 3.3 V logic is used, and the maximum current source spec of the digital signal driver is 5 mA. Figure the B-E junction of the transistor drops 700 mV, so that leaves 2.6 V across R1. By Ohm's law: (2.6 V)/(5 mA) = 520 Ω, so we'll round up to the nearest common 5% value of 560 Ω.

Now you can work backwards and find the minimum base current. Let's say the digital output is only guaranteed to be at 3.0 V at the full source current. That leaves 2.3 V across R1, which could be as high as 588 Ω. (2.3 V)/(588 Ω) = 3.9 mA.

Q1 must be rated to withstand whatever the power voltage is. In your case, that's only 5 V, but this method works regardless of what it is, as long as the tranistor can handle it.

D1 is needed in the general case where the load may be at least somewhat inductive. Consider the case of the load being a pure inductor. If Q1 is suddenly switched off, the instantaneous inductor current will keep flowing somewhere. Without D1 that somewhere is achieved by raising the collector voltage to the point where the transistor conducts despite it being switched off. This requires a high voltage and can damage the transistor and other parts the load may be connected to. D1 provides a safe path for the inductive kickback current. D1 is not needed if driving a resistive load on the same board. Adding D1 whenever going off-board is a good idea since you no longer control what might get connected, and long leads have their own inductance, even if the load is not inductive.

The maximum load current is the base current times the transistor gain. In the example above, we decided that the minimum guaranteed base current is 3.9 mA. If the transistor is guaranteed to have a gain of 50 at that current, for example, then the circuit is good for loads that draw up to 195 mA.

Another fairly simple way to switch a load from a digital signal is to use a low side N-channel FET that can be driven directly from logic-level signals:

The FET is voltage-controlled, unlike the NPN transistor above, which is current-controlled. The FET gate looks like a capacitive load to the digital output. You have to be careful if the digital output is specified to work with some maximum capacitance. Most of the time, more capacitance on a digital output just slows the slew time.

In this simple circuit, the FET must be controllable from logic-level voltages. Such FETs are often called logic level FETs. For example, the IRLML2502 is specified for 80 mΩ maximum at 2.5 V gate drive.

The FET must be rated to withstand the power voltage when off. FETs that work at logic-level gate voltages usually don't go to high D-S voltages. The IRLML2502, for example, is only good to 20 V. Above 30 V you will have problems finding a logic level FET, and different gate drive will have to be considered.

The maximum load current of course can't be more than the maximum current the FET is rated for. However, power dissipation is usually the actual limiting factor. For example, the IRLML2502 is rated for 800 mW at at 70 °C ambient. That comes out to 250 mA using the 80 mΩ figure from above.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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