You are previewing Adventures in Raspberry Pi, 2nd Edition.
O'Reilly logo
Adventures in Raspberry Pi, 2nd Edition

Book Description

Start programming quickly with this super-fun guide to Raspberry Pi

Adventures in Raspberry Pi, 2nd Edition includes 9 cool projects that show you how to set up and start developing on your Raspberry Pi. Updated for the release of the Rev 3 board, this second edition covers all the latest features and tells you everything you need to know. Written specifically for 11-15 year-olds, this book uses the wildly successful, Raspberry Pi to explain the fundamentals of computing. You'll have a blast learning basic programming and system administration skills, beginning with the very basics of how to plug in the board and turn it on. Each project includes an instructional video so you can jump right in and start going through the lessons on your own.

This hands-on book gets you up and running fast, with fun projects that let you explore.

  • Learn how to "talk to" your Raspberry Pi

  • Create games and stories with Scratch

  • Program with Turtle Graphics and Python

  • Code music and create a Raspberry Pi jukebox

  • If you want to get started programming today, Adventures in Raspberry Pi is the ultimate hands-on guide.

    Table of Contents

      1. About the Author
      2. Acknowledgments
      3. Introduction
        1. What Is the Raspberry Pi and What Can You Do With It?
        2. Who Should Read This Book?
        3. What You Will Learn
        4. What You Will Need for the Projects
        5. How This Book Is Organised
        6. The Companion Website
        7. Conventions
        8. Reaching Out
      4. Adventure 1: You Have a Raspberry Pi. Now What?
        1. What Hardware Do You Need?
        2. What Other Equipment Is Helpful?
        3. Setting Up the Raspberry Pi
          1. Downloading and Copying the Raspbian Operating System
            1. Preparing an SD Card to Store Your Software
            2. Making It Easy with NOOBS
          2. Plugging in the Hardware
          3. Installing and Configuring the Software
        4. Logging in to Your Raspberry Pi
        5. Exploring the Desktop in Raspbian
        6. Shutting Down Your Raspberry Pi
        7. Backing up an SD Card Image
      5. Adventure 2: Taking Command of Your Raspberry Pi
        1. Exploring the Terminal
        2. Commands for Navigating Through Your File System
        3. Understanding sudo
        4. Launching Programs from the Command Line
        5. Managing Files and Directories
        6. Installing and Updating Applications
          1. Downloading and Installing Applications
          2. Learning More About an Application
          3. Upgrading Your Apps
        7. Editing Files
        8. Using Shutdown and Restart Commands
        9. Continuing Your Text Adventure
      6. Adventure 3: Creating Stories and Games with Scratch
        1. Getting Started with Scratch
          1. The Scratch Interface
          2. A Quick Hello from Scratch Cat
        2. Setting the Stage
        3. Creating Costumes and Original Sprites
          1. Using the Scratch Sprite Image Library
          2. Editing an Existing Sprite
          3. Creating Your Own Original Sprites
        4. Animating a Crazy Monkey
        5. Creating an Adventure Role-Playing Game
          1. Creating Your Sprite and Stage
          2. Setting the Start Position of the Adventurer Sprite
          3. Creating Variables: Including Health Points for the Adventurer Sprite
          4. Controlling the Direction and Movement of the Adventurer Sprite
          5. Entering a Cave and Switching Backgrounds
            1. Adding a Script to Make the Adventurer Sprite Move Between Backgrounds
            2. Adding a Script to Switch the Stage
            3. Creating an Enchanted Key to Exit the Cave and Giving Extra Health Points
            4. Using “if” Statements to Show and Hide Sprites
          6. Creating Health-Point-Stealing Sprites
          7. Improving the Movement of the Adventurer Sprite Using “if” Blocks
          8. Creating a Game Over Screen
          9. Ideas for Improvements to Your Game
      7. Adventure 4: Programming Shapes with Turtle Graphics
        1. Scratch Turtle Graphics
          1. Using Pen Down and Pen Up
          2. Drawing Simple Shapes
          3. Using “clear” and Setting a Start Point
          4. Using Variables Instead of Values
          5. Changing the Size and Colour of <br xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops"></br>the Penthe Pen
          6. Creating Spiral Patterns
          7. Using User Input to Determine the Number of Sides
        2. Python Turtle Graphics
          1. Introducing Python Modules
          2. The IDLE Environment and the Interpreter Window
          3. Using the Turtle Module in Python
            1. Using a Text Editor
            2. Using “for” Loops and Lists
          4. The “range” Function
          5. Other Python Turtle Module Commands
            1. Pen Up and Pen Down
            2. Setting the Pen Colour and Size
            3. Stamping
        3. Some Super Spirals
        4. Further Adventures with Python Turtle
      8. Adventure 5: Programming with Python
        1. Getting Set Up for Python
          1. Python Programming Language
          2. The IDLE Environment
          3. Programming in Python: Using a Function
        2. Using a Text Editor to Create a Code File
        3. Using the Python time and random Modules
        4. Python Text Adventure Game
          1. Getting User Input
          2. Using Conditionals
          3. Using a while Loop
          4. Using a Variable for Health Points
          5. Putting It All Together
          6. Defining Functions
            1. The get_input Function
            2. The handle_room Function
          7. Creating a Main Game Loop
        5. Continuing Your Python Adventure
      9. Adventure 6: Programming Minecraft Worlds on the Raspberry Pi
        1. Getting Started with Minecraft Pi
        2. Minecraft Pi Controls
        3. Your First Minecraft Pi Python Program
        4. Using Coordinates in Minecraft Pi
          1. Finding the Player’s Location
          2. Changing the Player’s Location
          3. Placing a Block
          4. Placing Multiple Blocks
        5. Creating a Diamond Transporter
        6. Sharing and Cloning Minecraft Pi Programs
        7. Further Adventures with Minecraft Pi
      10. Adventure 7: Coding Music with Sonic Pi
        1. Getting Started with Sonic Pi
        2. The Sonic Pi Interface
        3. Creating Your First Sounds with Sonic Pi
          1. Twinkle Twinkle Little Star
          2. Repeating Lines in a Loop
        4. First Electronic Track
          1. Using Different Synthesizer Sounds
          2. Using Prerecorded Samples
          3. Creating a Surprising Tune
          4. Using “rand” to Play Random Notes
          5. Using Algorithms
          6. Running Two Scripts at the Same Time
          7. Adding Effects
          8. Make a Recording of Your Music
        5. Further Adventures with Sonic Pi
      11. Adventure 8: Using the GPIO Pins on the Raspberry Pi
        1. Using a Raspberry Leaf Diagram
        2. Electronic Basics
        3. Using the Python Library to Control GPIO
        4. Do You Have a Rev 1 or a Rev 2 Board?
        5. Making an LED Blink
          1. Creating the LEDblink Python Code
          2. Connecting the LEDblink Components
          3. Running LEDblink.py as the Super User root
        6. Using a Button to Turn on an LED
          1. Creating the buttonLED Python Code
          2. Connecting the buttonLED Components
          3. Running buttonLED.py as the Super User root
        7. The Marshmallow Challenge
          1. Creating the Marshmallow Button
          2. Mapping Marshmallow Input to a Keyboard Key
          3. Scratch Marshmallow Game
        8. Further Adventures with GPIO Pins
      12. Adventure 9: The Big Adventure: Building a Raspberry Pi Jukebox
        1. An Overview of the Jukebox Project
        2. What You Will Need
        3. Part One: Creating the LCD Screen
          1. Preparing the LCD Screen by Adding Headers
          2. Mounting the LCD Screen and Wiring Up the Breadboard
          3. Adding Scripts to Drive the LCD Screen
        4. Part Two: Downloading and Playing MP3s
          1. Installing a Media Player and Getting Music Files
          2. Writing a Jukebox Python Program
        5. Part Three: Controlling the Jukebox with Buttons
          1. Connecting the Buttons
          2. Adapting Your Jukebox Program to Include GPIO Buttons
        6. Part Four: Displaying Jukebox Information on the LCD screen
        7. Finishing Up
      13. Appendix: Where to Go from Here
        1. Websites
        2. Clubs
        3. Inspiring Projects and Tutorials
        4. Videos
        5. Books and Magazines
      14. Glossary