Raspberry Pi Lab

Tag: electronics

Three Blink LED – Part Two

by on Jan.05, 2014, under Electronics, Projects

3LED-transparentA couple of days ago I created a circuit for a three led blinking circuit.  The circuit description and the Python code can be found in my previous post.

In that example, I drove the LEDs directly off the GPIO pin with a 560 ohm resister.  That worked well because the GPIO pin can provide 3.3 v at up to 16mA.  However, I reader suggested that driving the LEDs directly off the 5v power rail and switching them on and off with a transistor on the GPIO pin.

The readers was absolutely right.  The transistor is basically a digital switch.  It has three pins called the collector, emitter, and base.  The collector and emitter pins complete the circuit.  The base pin is the switch.  By connecting the base pin to the RPi’s GPIO and setting it to High (1), the circuit is complete and the LED lights up.  Setting the GPIO to low (0) opens the circuit and turns the LED off.

This allows the LED to get its power from some other source than the GPIO pin itself.  The RPI has a 5v pin that is capable of 300 mA.  This additional voltage and current would allow us to use more LEDs per GPIO pin or control other devices that require more than the GPIO is capable of providing..

In my new circuit I took the 5v pin of the RPi to a 560 ohm resistor.  The resistor connected to the positive leg of the LED which then connected its negative leg to the collector pin of an N2222 transistor.  The emitter leg of the transistor then connected to ground.  The base pin of the transistor connected to a GPIO pin.  I set op three of these LED circutis.  Red on GPIO 25.  Green on GPIO 23.  Blue on GPIO 18.

three led isolatedIt really didn’t matter which GPIO pins I used.

I chose these particular pins because those are the same pins I used in my previous Three LED Blink circuit.  Therefore the Python code did not have to change at all for this to work.  The GMail Notify example I posted will also work with this re-designed circuit.

As a side note… The 560 ohm resister is larger than the minimum resister needed for this circuit.  According to Ohm’s Law (I = V/R), the minimum resister value would be 150 ohms.  That is R = (5v – 2v) / 20mA = 150 ohms.  5v being the voltage supplied by the power rail and 2v being the requirement of my particular LED.  The difference, 3v, needts to be resisted away so as not to blow up the LED.  By using the 560 ohm resistor instead of the 150 ohm minimum, my LED will shine sligntly less bright, but I’m ok with that.




Leave a Comment :, , , , , , , , , , more...


All entries, chronologically...

Our Partners

Please take a minute to visit our partners

Looking for something?

Search the Site

If you can't find what you are looking for, please leave a comment somewhere, subscribe to our feed and hopefully your question will be answered shortly, so please visit again!