Raspberry Pi Cookbook for Python Programmers

Raspberry Pi Cookbook for Python Programmers: Over 50 easy-to-comprehend tailor-made recipes to get the most out of the Raspberry Pi and unleash its huge potential using Python

Download

Introduction

Since the release of the Raspberry Pi computer in February 2012, hundreds of thousands of people have been introduced to a new way of computing. Modern home computers, tablets, and phones are typically focused on providing content to the user to consume, either as a passive viewer or through basic interaction via games and activities.

However, the Raspberry Pi turns this concept on its head. The idea is that the user provides the input and the imagination, and the Raspberry Pi becomes an extension of their creativity. The Raspberry Pi provides a simple, low-cost platform that you can use to experiment with and play with your own ideas. It won't feed you information; it will let you discover it firsthand.

This book takes everything I have found exciting and interesting with the Raspberry Pi and puts it in an easy-to-follow format.

I hope that people will read this book and start their own Raspberry Pi journey; it has so much to offer, and the book is aimed squarely at showing off what you can achieve with it.

Like any good cookbook, the pages should be worn and used, and it should be something that is always being pulled off the shelf to refer to. I hope it will become your own, personal, go-to reference.

What this book covers 
Chapter 1, Getting Started with a Raspberry Pi Computer, introduces the Raspberry Pi and explores the various ways that it can be set up and used, including how it can be used on a network and connected to remotely with another computer.

Chapter 2, Starting with Python Strings, Files, and Menus, guides us on how to take our irst steps using Python 3, start with the basics, manipulate text, use iles, and create menus to run our programs.

Chapter 3, Using Python for Automation and Productivity, explains the use of graphical user interfaces to create our own applications and utilities

Chapter 4, Creating Games and Graphics, explains how to create a drawing application and graphical games using the Tkinter Canvas.

Chapter 5, Creating 3D Graphics, discusses how we can use the hidden power of the Raspberry Pi's graphical processing unit to learn about 3D graphics and landscapes and produce our very own 3D maze for exploration.

Chapter 6, Using Python to Drive Hardware, establishes the fact that to experience the Raspberry Pi at its best, we really have to use it with our own electronics. It discusses how to create circuits with LEDs and switches, and use them to indicate the system status and provide control. Finally, it shows us how to create our own game controller and light display.

Chapter 7, Sense and Display Real-world Data, explains the use of an analog-to-digital convertor to provide sensor readings to the Raspberry Pi. We discover how to store and graph the data in real time as well as display it on an LCD text display. Finally, we transfer the data to the Internet, which will allow us to view and share the captured data anywhere in the world.

Chapter 8, Creating Projects with the Raspberry Pi Camera Module, teaches us how to use the Raspberry Pi camera module, creating our own applications to produce time-lapse videos, stop-frame animations, and a bedtime book reader controlled with QR codes.

Chapter 9, Building Robots, takes you through building two different types of robots (a RoverPi and a Pi-Bug). We look at motor and servo control, using sensors, and adding a compass sensor for navigation.

Chapter 10, Interfacing with Technology, teaches us how to use the Raspberry Pi to trigger remote mains sockets, with which we can control household appliances. We learn how to communicate with the Raspberry Pi over a serial interface and use a smartphone to control everything using Bluetooth. Finally, we look at creating our own applications to control USB devices.

Appendix, Hardware and Software List, provides us with the full list of the hardware components and modules used in the book, along with suitable places to purchase them from. A full list of the software used is also provided, along with links to documentation

What you need for this book
This book focuses on using the Raspberry Pi with Python 3; therefore, a basic Raspberry Pi setup is required. Chapters 1 to 5 of this book make use of the Raspberry Pi only; no additional hardware is required beyond a standard setup.

The standard setup will consist of the Raspberry Pi (Model A or Model B); an SD card installed with Raspbian; suitable micro USB power supply; and an HDMI-compatible screen, keyboard, and mouse. You will also be required to download and install various software packages; therefore, the Raspberry Pi should have a working Internet connection.

Chapter 1, Getting Started with a Raspberry Pi Computer, also describes how to use the screen/keyboard/mouse of a laptop or another computer to access the Raspberry Pi (you just need a network cable and power).

Chapter 6, Using Python to Drive Hardware, and Chapter 7, Sense and Display Real-world Data, show how electronic components can be connected to the Raspberry Pi's interfaces. These components will be needed in order to complete these chapters.

Chapter 8, Creating Projects with the Raspberry Pi Camera Module, requires the Raspberry Pi camera module for each of the projects (although a compatible USB webcam could be substituted by adjusting the code).

Chapter 9, Building Robots, uses a range of hardware and electronics to build your own robots. You can either use your own parts or a suitable kit for this.

Chapter 10, Interfacing with Technology, shows how additional hardware can be connected to the interfaces of the Raspberry Pi using various modules and kits.

A full list of the hardware used (and the possible places to purchase it from) has been provided in the Appendix, Hardware and Software List.

Who this book is for
This book is intended for anyone who wants to make the most of the Raspberry Pi experience. The book gradually introduces Python, starting with the basics and moving towards more advanced topics, such as using 3D graphics and interfacing with hardware.

Although you do not need to be familiar with Python, the Raspberry Pi, or electronics, this book touches on a wide range of topics. Ideally, you should give each chapter a try, see what you enjoy, and use that as a starting point to discover and learn more.

Each example in the book consists of full setup instructions, complete code listings, and a walk-through of what you did and why. This will allow you to get results quickly, and most importantly, understand how you achieved them.

All the examples are written using Python 3, with clear and detailed explanations of how everything works so that you can adapt and use all the information in your own projects.

As you progress through the book, it will explain how to structure and develop your code eficiently, building on the various techniques that can be applied as you progress. By the end, you will have a toolset of skills that you can apply on whatever your imagination inspires you to do.
Share This