Book Image

Raspberry Pi Computer Architecture Essentials

By : Andrew K. Dennis, Teemu O Pohjanlehto
Book Image

Raspberry Pi Computer Architecture Essentials

By: Andrew K. Dennis, Teemu O Pohjanlehto

Overview of this book

With the release of the Raspberry Pi 2, a new series of the popular compact computer is available for you to build cheap, exciting projects and learn about programming. In this book, we explore Raspberry Pi 2’s hardware through a number of projects in a variety of programming languages. We will start by exploring the various hardware components in detail, which will provide a base for the programming projects and guide you through setting up the tools for Assembler, C/C++, and Python. We will then learn how to write multi-threaded applications and Raspberry Pi 2’s multi-core processor. Moving on, you’ll get hands on by expanding the storage options of the Raspberry Pi beyond the SD card and interacting with the graphics hardware. Furthermore, you will be introduced to the basics of sound programming while expanding upon your knowledge of Python to build a web server. Finally, you will learn to interact with the third-party microcontrollers. From writing your first Assembly Language application to programming graphics, this title guides you through the essentials.
Table of Contents (18 chapters)
Raspberry Pi Computer Architecture Essentials
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Interacting with audio through GPIO


Now we are going to build upon what we learned in the previous chapter with regards to GPIO pins. We looked very briefly at how we can take a reading from the GPIO pins using Python. However, since we had no hardware connected to the GPIO pin, we got a reading of 0.

The following project involves connecting a number of buttons to the GPIO pins so we can use the input value when pressed to switch between MP3 files.

Before building the hardware, there are a number of software libraries we need to install so we can import them into our program.

So let's start by looking at these.

Installing the audio drivers

We are going to be installing the audio drivers for ALSA onto Raspbian first.

As discussed in the introduction, ALSA is used to provide an audio interface for Linux to the Raspberry Pi's hardware.

The two libraries we will install are alsa-utils and mpg123.

The alsa-utils library contains a number of utilities that are handy for controlling a sound card via Linux...