Contents:

Chapter 1. Introduction.

· What is the Raspberry Pi?

· What can you do with a Raspberry Pi?

· A Tour of the Raspberry Pi

· Setting Up

· Booting Up

· Summary

Chapter 2. Getting Started.

The Raspberry Pi uses Linux as its operating system. This chapter introduces Linux and shows the reader how to use the desktop and command line.

· Linux

· The Desktop

· The Internet

· Applications

· Internet Resources

· Summary

Chapter 3. Python Basics.

The time has come to start creating some of your own programs for the Raspberry Pi. The language that we are going to use is called Python and it has the great benefit that it is easy to learn, whilst at the same time being powerful enough to create some interesting programs, including the use of graphics and some simple games.

· What is a Programming Language?

· IDLE

· Numbers

· Variables

· For Loops

· Simulating Dice

· If

· While

· Summary

Chapter 4. Strings, Lists and Dictionaries.

This chapter could have had ‘and Functions’ added to its title but it was already long enough. In this chapter, you will first explore and play with the various ways of representing data and adding some structure to your programs in Python. You will then put it all together in the simple game Hangman.

· String Theory

· Lists

· Functions

· Hangman

· Dictionaries

· Tuples

· Exceptions

· Summary of Functions

· Summary

Chapter 5. Modules, Classes and Methods.

In this chapter, we will explain how to use and make our own modules such as the ‘random’ module that we used in the last chapter.

We will also explain how Python implements something called object-orientation. Object-orientation allows programs to be structured into classes, each responsible for their own behavior. This helps to keep a check on the complexity of our programs and generally makes them easier to manage.

· Modules

· Object-Orientation

· Defining Classes

· Inheritance

· Summary

Chapter 6. Files and Internet.

Python makes it easy for your programs to use files and connect to the. You can read data from files, write it to files and fetch content from the Internet, or even check for new mail or tweet all from your program.

· Files

· Pickling

· Internet

· Summary

Chapter 7. Graphical User Interfaces.

Everything we have done so far has been very text-based. Our Hangman game would not have looked out of place on a 1980’s home computer. This chapter will show you how to create applications with a proper graphical user interface (GUI).

· Tkinter

· Hello World

· Temperature Converter

· Other GUI Widgets

· Dialogs

· Menus

· The Canvas

· Summary

Chapter 8. Games Programming.

This chapter will introduce you to a very handy library called Pygame, and get you started using it to build a simple game.

· What is Pygame?

· Hello Pygame

· A Raspberry Game

· Summary

Chapter 9. Interfacing Hardware.

In this chapter we explore the various ways of connecting the Pi to electronic devices using the GPIO, using some of the first products that have become available to help you do this.

· GPIO Pin Connections

· Direct connection to GPIO Pins

· Expansion Boards

· Prototyping Boards

· Arduino and Pi

· Summary

Chapter 10. Prototyping Project (Clock).

In this chapter, we will build, what can only be seen as a grossly over-engineered LED digital clock. We will be using a Raspberry Pi, Adafruit’s Cobbler lead some breadboard and a 4 digit LED display.

· What You Need

· Hardware Assembly

· Software

· Phase Two

· Summary

Chapter 11. The RaspiRobot.

In this chapter, you will learn how to use the Raspberry Pi as the brain for a simple robot rover. The Pi will take commands from a wireless USB keyboard and control the power to motors attached to a robot chassis kit. The Robot will also optionally have an ultrasonic range finder that will tell it how far away it is from obstacles and an LCD screen attached to the robot that displays information from the range finder.

· What You Need

· Phase 1. A Basic Rover

· Hardware Assembly

· Phase 2. Adding a Rangefinder and Screen

· Summary

Chapter 12. What Next?

In this chapter, we provide some pointers for different ways of using your raspberry Pi and also other resources that are available for you to use, both in programming the Raspberry Pi and making use of it for interesting uses around the home.

· Linux Resources

· Python Resources

· Raspberry Pi Specific Resources

· Other Programming Languages

· Applications and Projects

· Summary

Errata:

Page 1. ‘Its small’ should be: it’s small – well, detail is important!

Page 36. near the bottom ‘True AND True’ should read ‘True and True’. [thanks to Brian MacKenzie]

Page 49 before the first code example. There should be some more text that says: ‘The play function uses a global variable called lives_remaining that is initialized with the code: livesRemaining = 14

Page 50 near the bottom and 51 1/3 way down the page. the references to ‘print_word’ in the discussion should be to ‘print_word_with_blanks’. [thanks to Brian MacKenzie]

Page 57 near the top. ‘Python lets you do a couple of next tricks’ should read: ‘Python lets you do a couple of neat tricks’ [thanks to Brian MacKenzie]

Page 71 3/4 of the way down the page: ‘ The method simply returns the result of multiplying the value passed in by self.scale’ should read: ‘ The method simply returns the result of multiplying the value passed in by self.factor’ [thanks to Karl Cookson]

Page 117, last paragraph – “it was been developed”, should be “it has been developed” [thanks to Karl Cookson]

Page 127 last paragraph – “need two hit”, should be “need to hit” [thanks to Karl Cookson]

Other Notes

I should mention somewhere that the super user and user password by default is ‘raspberry’

Although IDLE indents for you, it is worth noting that it uses 4 spaces for indentation and no tabs, so beware if you use other editors.