Interfacing a circuit to the Raspberry Pi GPIO P1 connector and blinking an LED is very simple. Here is a very simple circuit, which employs the ULN2803A Darlington array IC. This very versatile IC is low cost and simple to use. Back in the prehistoric days, they cost just 11 pence, however you can still get them at that price today.
Usually, I would use a transistor to drive an LED; but it is much more exciting and fun using a Darlington array IC because the focus is more on interfacing and making the LED blink. The eBay rate is ten chips for two pounds, which is good value if you need to teach a class.
This IC provides you with eight open collector outputs to drive loads. Each output provides 500 mA of drive current for sinking; hence, you can use it for controlling high-power LEDs and relays. It has built-in clamp diodes, which are useful when switching inductive loads such relays and motors.
Here is a typical circuit diagram using this chip. I am using the Raspberry Pi GPIO pins (10, 11, 12, 13, 15, 16, 18, 22), which are just an arbitrary set of pins I chose; because I just want to blink a couple of LEDs for fun.
Series Resistor Value
In this circuit, the LED will be driven with a current of 20 mA (0.02 A). The forward voltage rating of this LED is 1.7 V and the power supply is 5 V, therefore the voltage across the series resistor has to be (5 – 1.7), which is 3.3 V.
Since V = 3.3 V, and I = 0.02 A, we can use Ohm’s Law to calculate the value of the resistor.
R = V / I
Therefore, a series resistor of value 165 Ω works well.
The outputs of this chip are “open collector” which means that when the Darlington pair is saturated (fully switched ON) they provide a ground to the circuit. The current from the +5 V rail goes through the LED, through the resistor R, through the collector, and finally sinks to ground.
In this circuit, the ULN2803A IC uses the same power rails as the Raspberry Pi. Hence, header pin 2 (+5 V) and pin 6 (GND) connect to the chip. This is good enough for driving small loads such as a few LEDs. However, you should bear in mind that the Raspberry Pi board B has a 750 mA poly fuse that will trip if the IC draws more current to drive the load. If you have eight LEDs drawing 20 mA each, then 160 mA is used. An obvious solution is to use a separate power supply to drive the IC and the LEDs.
This Article Continues...Raspberry Pi Board B GPIO Header
Raspberry Pi GPIO Header Pinout
GPIO Header Pin Mapping
Raspberry Pi GPIO Header Pin Protection
Raspberry Pi GPIO Pinout
Raspberry Pi GPIO Interfacing and LED Blinking
Raspberry Pi GPIO Interface Circuit
Raspberry Pi Motor Controller
Related ArticlesEasy Raspberry Pi GPIO Projects
The Cambridge Boffin: Raspberry Pi GPIO Buffer Project
GPIO Cable Raspberry Pi
Raspberry Pi Pinout