Adventures in Raspberry Pi 2e
Buy Rights Online Buy Rights

Rights Contact Login For More Details

  • Wiley

More About This Title Adventures in Raspberry Pi 2e

English

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 PiCreate games and stories with ScratchProgram with Turtle Graphics and PythonCode 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.

English

Carrie Anne Philbin is a Google Certified and Raspberry Pi Certified Computing Teacher. She is also the founder and presenter of the award winning Gurl Geek Diaries (www.geekgurldiaries.co.uk). Currently, Carrie Anne is working with the Raspberry Pi Foundation to improve the teaching of Computing in schools

English

About the Author v

Acknowledgments vi

Introduction 1

Adventure 1 You Have a Raspberry Pi Now What? 9

What Hardware Do You Need? 10

What Other Equipment Is Helpful? 12

Setting Up the Raspberry Pi 14

Downloading and Copying the Raspbian Operating System 14

Preparing an SD Card to Store Your Software 15

Making It Easy with NOOBS 17

Plugging in the Hardware 18

Installing and Configuring the Software 19

Logging in to Your Raspberry Pi 22

Exploring the Desktop in Raspbian 23

Shutting Down Your Raspberry Pi 25

Backing up an SD Card Image 25

Adventure 2 Taking Command of Your Raspberry Pi 27

Exploring the Terminal 29

Commands for Navigating Through Your File System 31

Understanding sudo 35

Launching Programs from the Command Line 35

Managing Files and Directories 36

Installing and Updating Applications 37

Downloading and Installing Applications 37

Learning More About an Application 38

Upgrading Your Apps 39

Editing Files 39

Using Shutdown and Restart Commands 41

Continuing Your Text Adventure 41

Adventure 3 Creating Stories and Games with Scratch 45

Getting Started with Scratch 46

The Scratch Interface 47

A Quick Hello from Scratch Cat 48

Setting the Stage 50

Creating Costumes and Original Sprites 52

Using the Scratch Sprite Image Library 52

Editing an Existing Sprite 52

Creating Your Own Original Sprites 53

Animating a Crazy Monkey 53

Creating an Adventure Role-Playing Game 59

Creating Your Sprite and Stage 59

Setting the Start Position of the Adventurer Sprite 60

Creating Variables: Including Health Points for the Adventurer Sprite 61

Controlling the Direction and Movement of the Adventurer Sprite 63

Entering a Cave and Switching Backgrounds 64

Adding a Script to Make the Adventurer Sprite Move

Between Backgrounds 64

Adding a Script to Switch the Stage 66

Creating an Enchanted Key to Exit the Cave and Giving Extra

Health Points 67

Using "if" Statements to Show and Hide Sprites 69

Creating Health-Point-Stealing Sprites 70

Improving the Movement of the Adventurer Sprite Using "if" Blocks 71

Creating a Game Over Screen 72

Ideas for Improvements to Your Game 73

Adventure 4 Programming Shapes with Turtle Graphics 77

Scratch Turtle Graphics 78

Using Pen Down and Pen Up 79

Drawing Simple Shapes 80

Using "clear" and Setting a Start Point 82

Using Variables Instead of Values 82

Changing the Size and Colour of the Pen 83

Creating Spiral Patterns 84

Using User Input to Determine the Number of Sides 86

Python Turtle Graphics 86

Introducing Python Modules 87

The IDLE Environment and the Interpreter Window 87

Using the Turtle Module in Python 88

Using a Text Editor 90

Using "for" Loops and Lists 91

The "range" Function 93

Other Python Turtle Module Commands 94

Pen Up and Pen Down 94

Setting the Pen Colour and Size 95

Stamping 95

Some Super Spirals 95

Further Adventures with Python Turtle 97

Adventure 5 Programming with Python 101

Getting Set Up for Python 102

Python Programming Language 102

The IDLE Environment 102

Programming in Python: Using a Function 103

Using a Text Editor to Create a Code File 106

Using the Python time and random Modules 108

Python Text Adventure Game 112

Getting User Input 112

Using Conditionals 113

Using a while Loop 116

Using a Variable for Health Points 118

Putting It All Together 119

Defining Functions 121

The get_input Function 121

The handle_room Function 122

Creating a Main Game Loop 122

Continuing Your Python Adventure 126

Adventure 6 Programming Minecraft Worlds on the Raspberry Pi 129

Getting Started with Minecraft Pi 130

Minecraft Pi Controls 132

Your First Minecraft Pi Python Program 133

Using Coordinates in Minecraft Pi 135

Finding the Player’s Location 135

Changing the Player’s Location 137

Placing a Block 138

Placing Multiple Blocks 139

Creating a Diamond Transporter 142

Sharing and Cloning Minecraft Pi Programs 145

Further Adventures with Minecraft Pi 146

Adventure 7 Coding Music with Sonic Pi 149

Getting Started with Sonic Pi 150

The Sonic Pi Interface 151

Creating Your First Sounds with Sonic Pi 153

Twinkle Twinkle Little Star 155

Repeating Lines in a Loop 158

First Electronic Track 160

Using Different Synthesizer Sounds 160

Using Prerecorded Samples 161

Creating a Surprising Tune 163

Using "rand" to Play Random Notes 163

Using Algorithms 164

Running Two Scripts at the Same Time 166

Adding Effects 167

Make a Recording of Your Music 167

Further Adventures with Sonic Pi 168

Adventure 8 Using the GPIO Pins on the Raspberry Pi 171

Using a Raspberry Leaf Diagram 172

Electronic Basics 175

Using the Python Library to Control GPIO 177

Do You Have a Rev 1 or a Rev 2 Board? 177

Making an LED Blink 179

Creating the LEDblink Python Code 180

Connecting the LEDblink Components 181

Running LEDblink.py as the Super User root 182

Using a Button to Turn on an LED 184

Creating the buttonLED Python Code 184

Connecting the buttonLED Components 185

Running buttonLED.py as the Super User root 186

The Marshmallow Challenge 187

Creating the Marshmallow Button 188

Mapping Marshmallow Input to a Keyboard Key 190

Scratch Marshmallow Game 192

Further Adventures with GPIO Pins 195

Adventure 9 The Big Adventure: Building a Raspberry Pi Jukebox 197

An Overview of the Jukebox Project 198

What You Will Need 199

Part One: Creating the LCD Screen 200

Preparing the LCD Screen by Adding Headers 200

Mounting the LCD Screen and Wiring Up the Breadboard 201

Adding Scripts to Drive the LCD Screen 203

Part Two: Downloading and Playing MP3s 205

Installing a Media Player and Getting Music Files 205

Writing a Jukebox Python Program 208

Part Three: Controlling the Jukebox with Buttons 212

Connecting the Buttons 212

Adapting Your Jukebox Program to Include GPIO Buttons 214

Part Four: Displaying Jukebox Information on the LCD screen 216

Finishing Up 221

Appendix Where to Go from Here 223

Websites 223

Clubs 225

Inspiring Projects and Tutorials 226

Videos 226

Books and Magazines 227

Glossary 229

Index 235

loading