Table of Contents

Copyright

Brief Table of Contents

Table of Contents

Preface

Acknowledgments

About this book

1. Getting started

Chapter 1. Meet Raspberry Pi

What is the Raspberry Pi?

Exploring your Raspberry Pi’s parts: hardware

Giving your Pi a cozy home: Pi cases

The brain of your Pi: system on a chip

Connecting a keyboard and mouse: USB ports

Storing memories: your Pi gets a memory card

Connecting a TV or monitor: HDMI port

Other ports and connections

Powering your Pi: microUSB power port

It’s alive! Plugging in the Pi

Getting your Pi running: software

Installing the Raspbian operating system

Configuring the operating system: making it yours

Saving your configuration and rebooting

Getting around: learning Raspbian

Finding and opening applications on your Raspberry Pi

Your files and folders

Writing code

Fruit Picker Extra: shopping at the Pi Store

Challenge

Scavenger hunt

Summary

Chapter 2. Exploring Python

Playing with Python

Discovering Python’s mathematical operators

Adding and subtracting

Multiplying and dividing

Figuring out whole numbers and remainders

Exponents

Square roots

Challenge: stacking Pis!

Storing information using variables

Creating variables and assigning values

Displaying variable values

Storing strings in variables

Changing the value of variables

Displaying text on a screen

Using the print function

Troubleshooting

Creating programs

Writing Python programs with IDLE

Starting a new program

Saving programs

Python interpreting the program

Fruit Picker Extra: creating documents

Writing silly things and saving them

Challenges

The matrix

Building a brick wall

Pi electrons

Summary

2. Playing with Python

Chapter 3. Silly Sentence Generator 3000: creating interactive programs

Creating a welcome message

Starting a new program

Saving the program

Adding notes in your code

Using hashtags for comments

Getting and storing information

Joining strings

Using more than one input

Building the sentence

Troubleshooting

Completing the program: displaying the silly sentence

Fruit Picker Extra: Minecraft Pi

What’s Minecraft?

Launching Minecraft Pi

Python programming interface to Minecraft Pi

Challenges

Knight’s Tale Creator 3000

Subliminal messages

Summary

Chapter 4. Norwegian Blue parrot game: adding logic to programs

Displaying the game introduction

Creating the game welcome message and instructions

Collecting input from the player

Using if statements to respond to users in different ways

Practicing if statements

Using while loops to repeat things

A closer look at while loops

Breaking out of a while loop

Practicing while loops

Using Python code libraries to generate random numbers

Fruit Picker Extra: Scratch

Challenges

Summary

Chapter 5. Raspi’s Cave Adventure

Project introduction: Raspi’s Cave Adventure

Left cave

Right cave

Hey wait, you need a plan (flow diagrams)

Which way should Raspi go? (checking input)

Handling unexpected input

Turning flow diagrams into code

Simplify! Making your own functions

Finishing the left cave

Exploring the right cave

Troubleshooting

Fruit Picker Extra: playing video

Live streaming: exploring from your Pi

Challenges

Introducing dramatic pauses

Random demise

Play again?

Scream!

Summary

3. Pi and Python projects

Chapter 6. Blinky Pi

Setting up your Pi for physical computing

GPIO pins

Breaking out the GPIO pins to a breadboard

Breadboard basics

Building the LED circuit

Step 1. Connect the jumper from GPIO pin 21

Step 2. Add the red LED

Step 3. Connect a resistor

Software: blinkLED program

Running the program

blinkLED: how it works

Adding more LEDs

Building the circuit

Multiple LEDs: program it!

Challenges

Wave pattern

Simon Says

Random blinking

Summary

Chapter 7. Light Up Guessing Game

Guessing Game design

Hardware: building the circuit

Numbers, numbers, numbers!

Wiring an RGB LED

Circuit sketch

Software: LEDGuessingGame program

Setting up the GPIO pins for the RGB LED

Main game loop and logic

Guessing Game Loop and logic

Adding the Play Again Loop and logic

Playing the game

Troubleshooting

Challenges

Game winner

Easter egg

Warmer and colder

Darth Vader surprise

Summary

Chapter 8. DJ Raspi

Project overview

Setting up your Pi to play sounds

OMXPlayer and MP3s

Troubleshooting

Hardware: building the circuit

Wiring a button

Circuit sketch

Adding the second button

Software: the DJ Raspi program

Setting up the Pi: initializing the buttons

Getting a list of sounds

Getting a value of an item stored in a list

Getting the length of a list

Building a list of sound files with the os library

Playing a sound when a button is pressed

Functions!

Testing: your first gig as DJ Raspi

Troubleshooting

Challenges

Double button press surprise

Yoda Magic 8 Ball

Continuing to explore

Summary

Appendix A. Raspberry Pi troubleshooting

Making sure your Pi has power

Checking the connection to your TV or monitor

Pi starts booting up but then stops

Making your Pi a new SD card

Reformatting your SD card

Problems not covered here

Appendix B. Raspberry Pi ports and legacy boards

Raspberry Pi ports

Connecting to a wireless network

3.5 mm audio/video port

Camera Serial Interface: connecting a camera

Ethernet port

TV or monitor connection options

Legacy boards

Raspberry Pi 1 Model B

Raspberry Pi 1 Model B+

Other boards

Appendix C. Solutions to chapter challenges

Chapter 1

Chapter 2

The Matrix

Building a brick wall

Pi electrons

Chapter 3

Knight’s Tale Creator 3000

Subliminal messages

Chapter 4

Rock, Paper, Scissors!

Chapter 5

Introducing dramatic pauses

Random demise

Play again?

Chapter 6

Wave pattern

Simon says

Random blinking

Chapter 7

Game winner

Easter egg

Warmer and colder

Darth Vader surprise

Chapter 8

Double button press surprise

Yoda Magic 8 Ball

Appendix D. Raspberry Pi projects

Halloween heads

Time-lapse photography

Raspberry Pi robot

Index

List of Figures

List of Listings

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.194.57