Element 14 Raspberry Pi User Manual page 29

Table of Contents

Advertisement

We've shown you how to send output via the GPIO,
but as the name suggests, they can also receive input.
With this, it's even more important to
ensure that you don't send too much
power into the pins. To get input, just set
the mode to input with
<pin number> in and
value with
gpio –g read <pin number>
This hardware can display any eight bits
of information, so you don't have to limit
it to displaying just IP addresses. For
example, you could make a modified
version of the camera controller script to
use the LEDs to indicate its progress.
You can find details on the full selection of
GPIO pins at bit.ly/JTlFE3. If you design your
Ohm's Law
There are two key ways of measuring
electricity: voltage and current. Voltage
(measured in volts) is the amount of
energy a given quantity of electrons has,
while current (measured in amps) is the
amount of electrons flowing past a point.
The two are intimately connected by
Ohm's law which states: Voltage =
Current x Resistance, or V=IR. You can
use this connection to make sure you
don't accidentally toast your Raspberry
Pi by pushing too much current into
it. The exact setup of the Pi is a little
complex. If you wish to delve into it,
Gert van Loo (one of the designers)
has put together an explanation, which
can be found at:
bit.ly/Qp4PMl
Raspberry Pi User Guide.indd 29
own circuits, or use ones off the web, make
sure you use the right pins for your board.
You don't have to limit yourself to
gpio –g mode
just switching pins on and off. The Pi
then read the
supports a few methods of passing
.
larger amounts of data through the
GPIO. The two most common of these
are Serial Peripheral Interface bus (SPI)
and Inter-Intergrated Circuit (I²C).
There are a number of devices available
that use these, and plenty of information
online to help get you started. So
what's stopping you? Get out your
soldering iron and build a robot army.
As a rough rule of thumb, you can expect
to draw voltage out of a GPIO pin at 3.3V,
and you shouldn't draw more than 16mA,
or push more than this into an input pin.
This is the maximum current; you should
aim to use less. So, with Ohm's law we
know V=IR, so R=V/I. If we put in the data
from the Pi, and want to ensure we don't
damage it, we know that R must be greater
than 3.3/0.016, which is 206.25 Ohms.
Remember, this is the smallest amount
of resistance it's safe to use with a
GPIO output. You should aim for a
margin of safety several times above
this unless absolutely necessary. In our
circuits, we've used 1,000 Ohms, which
gives us a safety factor of almost 5.
29
08/07/2014 14:44

Hide quick links:

Advertisement

Table of Contents
loading

Related Products for Element 14 Raspberry Pi

Table of Contents