ELECTRONICS
Interfacing to single board computers
Mike Bedford shows you how to get more from your Raspberry Pi, Arduino or other SBC by getting to grips with interfacing circuitry.
OUR EXPERT
Mike Bedford With a degree in computer science, but a long standing interest in electronics, Mike likes to straddle the great divide with a foot in both camps -hardware and software.
F or many users, a major benefit of single board computers like the Raspberry Pi and Arduino products is the ease by which they can be interfaced to real-world hardware, and not just computer peripherals. As such, they’re commonly used at the heart of all sorts of innovative projects. Many devices can be attached to SBCs via standard interfaces like USB or I2C, and simple components like LEDs and pushbuttons can be connected to GPIO ports with an absolute minimum of additional electronics.
So you might think there’s no need to use any external electronics beyond the familiar current-limiting resistor that’s necessary for driving a LED, but some devices just can’t be interfaced to SBCs without some additional electronics. In other cases, without using some external circuitry you’d risk running out of GPIO pins, or you might have to use a larger SBC than you’d otherwise need to get enough GPIOs.
Here we look at how to use external interfacing circuits to attach devices that you couldn’t otherwise connect to your SBC, or to reduce the number of GPIO pins needed. This relates to any type of SBC, not just Raspberry Pis, but whatever you’re interfacing to, be sure to check the specification – most importantly the voltage levels and maximum current of its GPIO ports.
We’re going to be presenting circuits as schematics, but we’ll leave you to figure out how to implement them as real circuits, probably on a breadboard, stripboard or PCB. Several of the components we’ll be using are logic ICs in the 74HC family. Different members of the family provide different functionality, but for general info on these chips, take a look at the box on the opposite page.
Before looking at specifics, we should raise a general point. Some SBCs operate from a 3.3V supply, others use 5V. Because our instructions are generic, we’ll refer to these voltages as Vcc. Similarly, irrespective of whether it’s referred to as GND or 0V on your SBC, we’ll always refer to 0V.
More current, more voltage
Driving an LED from an SBC is a common requirement and it’s easy to achieve. LEDs will light with a forward voltage from about 1.6 to 3.1V, depending on the colour, so they can be driven directly from digital output pins that deliver a logic high. They usually work with a current of 10 or 12mA, which falls within the maximum current rating of most SBC’s GPIOs (on RPis, there is a limit of 16mA per pin, or 50mA per GPIO bank). All you need to drive a LED, therefore, is the current-limiting resistor that you’re probably familiar with.