ebook img

Adventures In Raspberry Pi PDF

258 Pages·2014·34.12 MB·english
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Adventures In Raspberry Pi

Adventures in Raspberry Pi® Carrie Anne Philbin 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 permis- sion 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 publica- tion 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 win- ning 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 appre- ciated. 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, sup- port and encouragement throughout. Contents About the Author v Acknowledgments vi Introduction 1 1 Adventure You Have a Raspberry Pi. Now What? . . . . . . 9 What Hardware Do You Need? ...........................................10 What Other Equipment Is Helpful? .......................................11 Setting Up the Raspberry Pi .............................................13 Downloading and Copying the Raspbian Operating System ...............13 Preparing an SD Card to Store Your Software .........................14 Making It Easy with NOOBS .......................................16 Plugging in the Hardware .............................................17 Installing and Configuring the Software ................................18 Logging in to Your Raspberry Pi ..........................................21 Exploring the Desktop in Raspbian .......................................22 Shutting Down your Raspberry Pi ........................................24 Backing up an SD Card Image ............................................24 2 Adventure 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 TABLE OF CONTENTS vii 3 Adventure 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 4 Adventure 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 viii ADVENTURES IN RASPBERRY PI

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.