13,99 €
Coding for kids is cool with Raspberry Pi and this elementary guide
Even if your kids don't have an ounce of computer geek in them, they can learn to code with Raspberry Pi and this wonderful book. Written for 11- to 15-year-olds and assuming no prior computing knowledge, this book uses the wildly successful, low-cost, credit-card-sized Raspberry Pi computer to explain fundamental computing concepts. Young people will enjoy going through the book's nine fun projects while they learn basic programming and system administration skills, starting with the very basics of how to plug in the board and turn it on.
Each project includes a lively and informative video to reinforce the lessons. It's perfect for young, eager self-learners—your kids can jump in, set up their Raspberry Pi, and go through the lessons on their own.
Help your children have fun and learn computing skills at the same time with Adventures in Raspberry Pi.
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 266
Veröffentlichungsjahr: 2013
This edition first published 2014
© 2014 Carrie Anne Philbin
Registered office
John Wiley & Sons Ltd, The Atrium, Southern Gate, Chichester, West Sussex, PO19 8SQ, United Kingdom
For details of our global editorial offices, for customer services and for information about how to apply for permission to reuse the copyright material in this book please see our website at www.wiley.com.
The right of the author to be identified as the author of this work has been asserted in accordance with the Copyright, Designs and Patents Act 1988.
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording or otherwise, except as permitted by the UK Copyright, Designs and Patents Act 1988, without the prior permission of the publisher.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books.
Designations used by companies to distinguish their products are often claimed as trademarks. All brand names and product names used in this book are trade names, service marks, trademarks or registered trademarks of their respective owners. The publisher is not associated with any product or vendor mentioned in this book. This publication is designed to provide accurate and authoritative information in regard to the subject matter covered. It is sold on the understanding that the publisher is not engaged in rendering professional services. If professional advice or other expert assistance is required, the services of a competent professional should be sought.
Trademarks: Wiley and the Wiley logo are trademarks or registered trademarks of John Wiley & Sons, Inc. and/ or its affiliates in the United States and/or other countries, and may not be used without written permission. Raspberry Pi is a registered trademark of Raspberry Pi Foundation. All other trademarks are the property of their respective owners. John Wiley & Sons, Ltd. is not associated with any product or vendor mentioned in the book.
A catalogue record for this book is available from the British Library.
ISBN 978-1-118-75125-1 (paperback); ISBN 978-1-118-75123-7 (ePub); ISBN 978-1-118-75122-0 (ePDF)
Set in 10/12.5 Chaparral Pro Light by Indianapolis Composition Services
Printed in the United Kingdom at Bell & Bain
For Mum & Dad—my best teachers.
Publisher’s Acknowledgements
Some of the people who helped bring this book to market include the following:
Editorial and Production
VP Consumer and Technology Publishing Director: Michelle Leete
Associate Director–Book Content Management: Martin Tribe
Associate Publisher: Chris Webb
Executive Commissioning Editor: Craig Smith
Development Editor: Sara Shlaer
Copy Editor: Grace Fairley
Technical Editor: David Whale
Editorial Manager: Jodi Jensen
Senior Project Editor: Sara Shlaer
Editorial Assistant: Anne Sullivan
Marketing
Associate Marketing Director: Louise Breinholt
Marketing Manager: Lorna Mein
Marketing Executive: Polly Thomas
Composition Services
Compositors: Jennifer Mayberry, Sarah Wright
Proofreader: Wordsmith Editorial
Indexer: Potomac Indexing, LLC
About the Author
Carrie Anne Philbin is a high school-level Computing and Google Certified Teacher and a member of the DfE Computing expert panel reviewing the new Computing School Curriculum in the UK. She is also the founder and presenter of the award winning Gurl Geek Diaries (www.geekgurldiaries.co.uk) and vice chair of the #include Computing At Schools initiative (http://casinclude.org.uk) to get more girls and minority groups into computing. Currently, Carrie Anne is working with the Raspberry Pi Foundation to improve the teaching of Computing in schools.
Acknowledgments
I would like to express my deep gratitude to the Raspberry Pi Foundation for allowing me to set my creativity free on their marvellous invention. In particular I’d like to thank Alex Bradbury and Dr Sam Aaron for their enthusiastic encouragement and patient guidance. Their willingness to give their time so generously is very much appreciated. I would also like to thank David Whale and the Raspberry Pi Community for their useful critiques of this work. Thanks to Jennifer Mayberry for her design work and Sarah Wright for much of the art.
Special thanks should also be given to the staff of Pimoroni for providing necessary equipment in order to complete elements of this book, as well as members of CAS #include and the Rainham Library Book Club, for keeping my progress on schedule with their kind words of encouragement.
My special thanks are also extended to my good friends: Emma, Sian, Helen, Viv, Lizi and Kylie who are a constant source of inspiration in my life.
Finally, I wish to thank my parents, brother and sister-in-law for their patience, support and encouragement throughout.
Table of Contents
Introduction
What Is the Raspberry Pi and What Can You Do With It?
Who Should Read This Book?
What You Will Learn
What You Will Need for the Projects
How This Book Is Organised
The Companion Website
Conventions
Reaching Out
Adventure 1: You Have a Raspberry Pi. Now What?
What Hardware Do You Need?
What Other Equipment Is Helpful?
Setting Up the Raspberry Pi
Downloading and Copying the Raspbian Operating System
Plugging in the Hardware
Installing and Configuring the Software
Logging in to Your Raspberry Pi
Exploring the Desktop in Raspbian
Shutting Down Your Raspberry Pi
Backing up an SD Card Image
Adventure 2: Taking Command of Your Raspberry Pi
Exploring the Terminal
Commands for Navigating Through Your File System
Understanding sudo
Launching Programs from the Command Line
Managing Files and Directories
Installing and Updating Applications
Downloading and Installing Applications
Learning More About an Application
Upgrading Your Apps
Editing Files
Using Shutdown and Restart Commands
Continuing Your Text Adventure
Adventure 3: Creating Stories and Games with Scratch
etting Started with Scratch
The Scratch Interface
A Quick Hello from Scratch Cat
Setting the Stage
Creating Costumes and Original Sprites
Using the Scratch Sprite Image Library
Editing an Existing Sprite
Creating Your Own Original Sprites
Animating a Crazy Monkey
ating an Adventure Role-Playing Game
Creating Your Sprite and Stage
Setting the Start Position of the Adventurer Sprite
Creating Variables: Including Health Points for the Adventurer Sprite
Controlling the Direction and Movement of the Adventurer Sprite
Entering a Cave and Switching Backgrounds
Creating Health-Point-Stealing Sprites
roving the Movement of the Adventurer Sprite Using “if” Blocks
Creating a Game Over Screen
Ideas for Improvements to Your Game
Adventure 4: Programming Shapes with Turtle Graphics
Scratch Turtle Graphics
Using Pen Down and Pen Up
Drawing Simple Shapes
Using “clear” and Setting a Start Point
Using Variables Instead of Values
Changing the Size and Colour of the Pen
Creating Spiral Patterns
Using User Input to Determine the Number of Sides
Python Turtle Graphics
Introducing Python Modules
The IDLE Environment and the Interpreter Window
Using the Turtle Module in Python
The “range” Function
Other Python Turtle Module Commands
Some Super Spirals
Further Adventures with Python Turtle
Adventure 5: Programming with Python
Getting Set Up for Python
Python Programming Language
he IDLE Environment
Programming in Python: Using a Function
Using a Text Editor to Create a code File
Using the Python time and random Modules
Python Text Adventure Game
ing User Input
Using Conditionals
Using a while Loop
Using a Variable for Health Points
Putting It All Together
Defining Functions
Creating a Main Game Loop
Continuing Your Python Adventure
Adventure 6: Programming Minecraft Worlds on the Raspberry Pi
Downloading and Installing Minecraft
Minecraft Pi Controls
Your First Minecraft Pi Python Program
Using Coordinates in Minecraft Pi
Finding the Player’s Location
Changing the Player’s Location
Placing a Block
lacing Multiple Blocks
Creating a Diamond Transporter
Sharing and Cloning Minecraft Pi Programs
Further Adventures with Minecraft Pi
Adventure 7: Coding Music with Sonic Pi
Getting Started with Sonic Pi
Sonic Pi Interface
Creating Your First Sounds with Sonic Pi
winkle Twinkle Little Star
Repeating Lines in a Loop
First Electronic Track
Using Different Synthesizer Sounds
Creating a Surprising Tune
Using “rand” to Play Random Notes
Using Algorithms
Running Two Scripts at the Same Time
Using the Mouse to Control Sound
Further Adventures with Sonic Pi
Adventure 8: Using the GPIO Pins on the Raspberry Pi
sing a Raspberry Leaf Diagram
Electronic Basics
Using the Python Library to Control GPIO
Do You Have a Rev 1 or a Rev 2 Board?
Making an LED Blink
ting the LEDblink Python code
Connecting the LEDblink Components
Running LEDblink.py as the Super User root
Using a Button to Turn on an LED
ting the buttonLED Python code
Connecting the buttonLED Components
Running buttonLED.py as the Super User root
The Marshmallow Challenge
Creating the Marshmallow Button
Mapping Marshmallow Input to a Keyboard Key
tch Marshmallow Game
Further Adventures with GPIO Pins
Adventure 9: The Big Adventure: Building a Raspberry Pi Jukebox
An Overview of the Jukebox Project
What You Will Need
Part One: Creating the LCD Screen
Preparing the LCD Screen by Adding Headers
Mounting the LCD Screen and Wiring Up the Breadboard
Adding Scripts to Drive the LCD Screen
Part Two: Downloading and Playing MP3s
Installing a Media Player and Getting Music Files
Writing a Jukebox Python Program
Part Three: Controlling the Jukebox with Buttons
Connecting the Buttons
Adapting Your Jukebox Program to Include GPIO Buttons
Part Four: Displaying Jukebox Information on the LCD screen
Finishing Up
Appendix: Where to Go from Here
Glossary
Introduction
Are you an intrepid adventurer? Do you like to try new things and learn new skills? Would you like to be a pioneer in creating technology? Do you own a Raspberry Pi, or are you considering getting one? If the answer is a resounding “Yes!” then this is the book for you.
What Is the Raspberry Pi and What Can You Do With It?
The Raspberry Pi is a computer. A very small computer. In fact, it is roughly the size of a credit card. Don’t be fooled by its size; as we know, good things come in small packages. However, the Raspberry Pi does not come in a package at all. It does not come in a case (although you can build one, as discussed in Adventure 1) and its circuit board and chips are fully visible, as you can see in Figure 1. You can plug a Raspberry Pi into a digital TV or monitor and use a USB keyboard and mouse with it, making it very easy to use, and because of its size you can easily transport it anywhere.
The Raspberry Pi gives you the opportunity to build and control a device that does what you want it to do. For example, you can deploy your very own robot arm, controlled by a program that you have written. You can design and create your own role-playing game, or produce beautiful computer art or music, all by using code.
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!
Lesen Sie weiter in der vollständigen Ausgabe!