Hello Raspberry Pi!
Python programming for kids and other beginners
Ryan Heitz
  • January 2016
  • ISBN 9781617292453
  • 320 pages
  • printed in black & white

Very well written and inspiring, for both kids and teachers!

Dr. Christian Mennerich, Mennerich Devoxx4Kids Team, Germany

A fun and imaginative way for kids and other beginners to take their first steps programming on a Raspberry Pi.

Table of Contents detailed table of contents



about this book

author online

about the author

Part 1: Getting Started

1. Meet Raspberry Pi

1.1. What is the Raspberry Pi?

1.2. Exploring your Raspberry Pi's parts: hardware

1.2.1. Giving your Pi a cozy home: Pi cases

1.2.2. The brain of your Pi: system on a chip

1.2.3. Connecting a keyboard and mouse: USB ports

1.2.4. Storing memories: your Pi gets a memory card

1.2.5. Connecting a TV or monitor: HDMI port

1.2.6. Other ports and connections

1.2.7. Powering your Pi: microUSB power port

1.2.8. It's alive!: plugging in the Pi

1.3. Getting your Pi running: software

1.3.1. Installing the Raspbian operating system

1.3.2. Configuring the operating system: making it yours

1.3.3. Saving your configuration and rebooting

1.4. Getting around: learning Raspbian

1.4.1. Finding and opening applications on your Raspberry Pi

1.4.2. Your files and folders

1.4.3. Writing code

1.5. Fruit Picker Extra: shopping at the Pi Store

1.6. Challenge

1.6.1. Scavenger hunt

1.7. Summary

2. Exploring Python

2.1. Playing with Python

2.2. Discovering Python's mathematical operators

2.2.1. Adding and subtracting

2.2.2. Multiplying and dividing

2.2.3. Figuring out whole numbers and remainders

2.2.4. Exponents

2.2.5. Square roots

2.2.6. Challenge: stacking Pis!

2.3. Storing information using variables

2.3.1. Creating variables and assigning values

2.3.2. Displaying variable values

2.3.3. Storing strings in variables

2.3.4. Changing the value of variables

2.4. Displaying text on a screen

2.4.1. Using the print function

2.4.2. Troubleshooting

2.5. Creating programs

2.5.1. Writing Python programs with IDLE

2.5.2. Starting a new program

2.5.3. Saving programs

2.5.4. Python interpreting the program

2.6. Fruit Picker Extra: creating documents

2.6.1. Writing silly things and saving them

2.7. Challenges

2.7.1. The matrix

2.7.2. Building a brick wall

2.7.3. Pi electrons

2.8. Summary

Part 2: Playing with Python

3. Silly Sentence Generator 3000: creating interactive programs

3.1. Creating a welcome message

3.1.1. Starting a new program

3.1.2. Saving the program

3.2. Adding notes in your code

3.2.1. Using hashtags for comments

3.3. Getting and storing information

3.4. Joining strings

3.4.1. Using more than one input

3.4.2. Building the sentence

3.4.3. Troubleshooting

3.5. Completing the program: displaying the silly sentence

3.6. Fruit Picker Extra: Minecraft Pi

3.6.1. What’s Minecraft?

3.6.2. Launching Minecraft Pi

3.6.3. Python programming interface to Minecraft Pi

3.7. Challenges

3.7.1. Knight's Tale Creator 3000

3.7.2. Subliminal messages

3.8. Summary

4. Norwegian Blue parrot game: adding logic to programs

4.1. Displaying the game introduction

4.1.1. Creating the game welcome message and instructions

4.2. Collecting input from the player

4.3. Using if statements to respond to users in different ways

4.3.1. Practicing if statements

4.4. Using while loops to repeat things

4.4.1. A closer look at while loops

4.4.2. Breaking out of a while loop

4.4.3. Practicing while loops

4.5. Using Python code libraries to generate random numbers

4.6. Fruit Picker Extra: Scratch

4.7. Challenge

4.8. Summary

5. Raspi's Cave Adventure

5.1. Project introduction: Raspi's Cave Adventure

5.1.1. Left cave

5.1.2. Right cave

5.2. Hey wait, you need a plan (flow diagrams)

5.3. Which way should Raspi go? (checking input)

5.3.1. Handling unexpected input

5.3.2. Turning flow diagrams into code

5.4. Simplify! Making your own functions

5.4.1. Finishing the left cave

5.4.2. Exploring the right cave

5.4.3. Troubleshooting

5.5. Fruit Picker Extra: playing video

5.5.1. Live streaming: exploring from your Pi

5.6. Challenges

5.6.1. Introducing dramatic pauses

5.6.2. Random demise

5.6.3. Play again?

5.6.4. Scream!

5.7. Summary

Part 3: Pi and Python Projects

6. Blinky Pi

6.1. Setting up your Pi for physical computing

6.1.1. GPIO pins

6.1.2. Breaking out the GPIO pins to a breadboard

6.1.3. Breadboard basics

6.2. Building the LED circuit

6.2.1. Step 1. Connect the jumper from GPIO pin 21

6.2.2. Step 2. Add the red LED

6.2.3. Step 3. Connect a resistor

6.3. Software: blinkLED program

6.3.1. Running the program

6.3.2. blinkLED: how it works

6.4. Adding more LEDs

6.4.1. Building the circuit

6.4.2. Multiple LEDs: program it!

6.5. Challenges

6.5.1. Wave pattern

6.5.2. Simon Says

6.5.3. Random blinking

6.6. Summary

7. Light Up Guessing Game

7.1. Guessing Game design

7.2. Hardware: building the circuit

7.2.1. Numbers, numbers, numbers!

7.2.2. Wiring an RGB LED

7.2.3. Circuit sketch

7.3. Software: LEDGuessingGame program

7.3.1. Setting up the GPIO pins for the RGB LED

7.3.2. Main game loop and logic

7.3.3. Guessing Game Loop and logic

7.3.4. Adding the Play Again Loop and logic

7.3.5. Playing the game

7.3.6. Troubleshooting

7.4. Challenges

7.4.1. Game winner

7.4.2. Easter egg

7.4.3. Warmer and colder

7.4.4. Darth Vader surprise

7.5. Summary

8. DJ Raspi

8.1. Project overview

8.2. Setting up your Pi to play sounds

8.2.1. OMXPlayer and MP3s

8.2.2. Troubleshooting

8.3. Hardware: building the circuit

8.3.1. Wiring a button

8.3.2. Circuit sketch

8.3.3. Adding the second button

8.4. Software: the DJ Raspi program

8.4.1. Setting up the Pi: initializing the buttons

8.4.2. Getting a list of sounds

8.4.3. Getting a value of an item stored in a list

8.4.4. Getting the length of a list

8.4.5. Building a list of sound files with the os library

8.4.6. Playing a sound when a button is pressed

8.4.7. Functions!

8.4.8. Testing: your first gig as DJ Raspi

8.5. Troubleshooting

8.6. Challenges

8.6.1. Double button press surprise

8.6.2. Yoda Magic 8 Ball

8.6.3. Continuing to explore

8.7. Summary


Appendix A: Raspberry Pi troubleshooting

A.1. Making sure your Pi has power

A.2. Checking the connection to your TV or monitor

A.3. Pi starts booting up but then stops

A.4. Making your Pi a new SD card

A.4.1. Reformatting your SD card

Appendix B: Raspberry Pi ports and legacy boards

B.1. Raspberry Pi ports

B.1.1. Connecting to a wireless network

B.1.2. 3.5 mm audio/video port

B.1.3. Camera Serial Interface: connecting a camera

B.1.4. Ethernet port

B.1.5. TV or monitor connection options

B.2. Legacy boards

B.2.1. Raspberry Pi 1 Model B

B.2.2. Raspberry Pi 1 Model B+

B.2.3. Other boards

Appendix C: Solutions to chapter challenges

C.1. Chapter 1

C.2. Chapter 2

C.2.1. The Matrix

C.2.2. Building a brick wall

C.2.3. Pi electrons

C.3. Chapter 3

C.3.1. Knight's Tale Creator 3000

C.3.2. Subliminal messages

C.4. Chapter 4

C.4.1. Rock, Paper, Scissors!

C.5. Chapter 5

C.5.1. Introducing dramatic pauses

C.5.2. Random demise

C.5.3. Play again?

C.6. Chapter 6

C.6.1. Wave pattern

C.6.2. Simon says

C.6.3. Random blinking

C.7. Chapter 7

C.7.1. Game winner

C.7.2. Easter egg

C.7.3. Warmer and colder

C.7.4. Darth Vader surprise

C.8. Chapter 8

C.8.1. Double button press surprise

C.8.2. Yoda Magic 8 Ball

Appendix D: Raspberry Pi projects

D.1. Halloween heads

D.2. Time-lapse photography

D.3. Raspberry Pi robot

About the Technology

The Raspberry Pi is a small, low-cost computer invented to encourage experimentation. The Pi is a snap to set up, and using the free Python programming language, you can learn to create video games, control robots, and maybe even write programs to do your math homework!

About the book

Hello Raspberry Pi! is a fun way for kids to take their first steps programming on a Raspberry Pi. First, you discover how to set up and navigate the Pi. Next, begin Python programming by learning basic concepts with engaging challenges and games. This book gives you an introduction to computer programming as you gain the confidence to explore, learn, and create on your own. The last part of the book introduces you to the world of computer control of physical objects, where you create interactive projects with lights, buttons, and sounds.

What's inside

  • Learn Python with fun examples
  • Write games and control electronics
  • Use Pygame for video game sounds and graphics
  • Loaded with programming exercises

About the reader

To use this book, you’ll need a Raspberry Pi starter kit, keyboard, mouse, and monitor. No programming experience needed.

About the author

Ryan Heitz is a teacher, programmer, maker, father, and big kid. He specializes in teaching kids to code in a fun and engaging way.

combo $24.99 pBook + eBook
eBook $19.99 pdf + ePub + kindle

FREE domestic shipping on three or more pBooks

A fantastic resource for young programmers. Ryan Heitz does a great job walking readers through examples ... I wish this book had been available when I first started to program!

Nathan Sperry, student Thomas Jefferson High School for Science and Technology

This book makes coding easy and fun to learn.

Matthew Giblin, age 13, Bradenton Preparatory Academy Dubai

A fantastic overview of the truly remarkable Raspberry Pi. My daughter Grace and I were thoroughly engrossed while working through the examples.

Dan Kacenjar, Wolters Kluwer