I'm trying to get my head around how to properly use NPN transistors to limit the needed current from my Raspberry PI GPIO.
I want to drive a Luxeon Rebel LED from Phillips (https://www.sparkfun.com/products/9637), and I have drawn up this kind of circuit for it:
I'm not that experienced with transistors, so I might be doing something very foolish here. But my thinking was that if I have a 9V battery, and I would like to use GPIO pin on my raspi, something like this might work.
I calculated the resistor value for the LED1 with the information from the sparkfun website information (typical forward voltage of ~3V) -> R = (9V – 3V) / 0.2A. So I got 30 Ohms from there.
The battery and raspi ground would be connected. Is there something I am doing in a stupid or even dangerous way ?
I want to understand how properly use NPN transistor for this kind of purpose..
Best Answer
With those value resistors, you need a transistor with at least 25 hfe, and more than 275mA collector current. ~6v / 22Ω = 0.272A (272mA) of current through the LED, and (3.3v - 0.6v) / 330Ω = 0.0081A (8.1mA) of current through the base.
A common 2n2222 transistor would work. Otherwise, you got it right. Also, you might want to go with the actual 30Ω or higher value resistor, to prevent overdriving the led.