Hardware Reference
In-Depth Information
may want to investigate a lower-level language such as C++ or even assembler running on a
dedicated real-time microcontroller .
If true real-time operation is required for your project, the Pi may be a bad choice. Instead,
consider using a microcontroller platform such as the popular open-source Arduino, or one
of the MSP430 family of microcontrollers from Texas Instruments. Both of these devices
can interface with the Pi either through the GPIO header or over USB, and provide a special-
ised real-time environment for control and sensing.
Installing the GPIO Python Library
Since the launch of the Pi, numerous developers have created software modules known as
libraries for making full use of its various functions. In particular, programmers have addressed
the Pi users' need to access the GPIO port without having to know low-level programming.
hese libraries are designed to extend the functionality of the base Python language, much
like the pygame software described in Chapter 11, “Python Basics”. Installing one of these
libraries gives Python the ability to easily address the Pi's GPIO port, although it means that
anyone planning to use the software you create will also have to download and install the
library before it will work.
here are several GPIO Python libraries available, but for the purpose of this section, we rec-
ommend that you use the raspberry-gpio-python library, which was at version 0.2.0 at
the time of writing. You can access this library from the Google Code website at the following
address: http://code.google.com/p/raspberry-gpio-python/
Although it's possible to download the Python library through a web browser, it's signiicantly
quicker to do so through the terminal as part of the installation process. Just follow these steps:
Open a terminal window on your Raspberry Pi from the Accessories menu, or use the
console if you haven't loaded a desktop environment.
Type wget http://raspberry-gpio-python.googlecode.com/files/RPi.
GPIO-0.2.0.tar.gz to download the library to your home directory. If a newer ver-
sion has been released, replace the version number— 0.2.0— with the current version.
Type tar xvzf RPi.GPIO-0.2.0.tar.gz to extract the contents of the ile. his
command is case-sensitive, so make sure to type the capital letters.
Type cd RPi.GPIO-0.2.0 to change to the newly created directory. Again, if you
downloaded a newer version of the library, replace the version number with that of the
downloaded version.
Type sudo python setup.py install to install the library into Python.
Search WWH ::




Custom Search