ebook img

Teach Yourself VISUALLY Raspberry Pi PDF

322 Pages·2014·83.474 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 Teach Yourself VISUALLY Raspberry Pi

Are you a visual learner? Do you prefer instructions You’ll learn to: that show you how to do something — and skip the • Set up your Raspberry Pi® long-winded explanations? If so, then this book is for ® • Select and install your OS Raspberry Pi you. Open it up and you’ll find clear, step-by-step screen shots that show you how to tackle more than 140 • Understand advanced commands Raspberry Pi tasks. Each task-based spread covers a • Use Scratch, Python, and Pygame single technique, sure to help you get up and running • Add custom hardware on Raspberry Pi in no time. Wiley. R © Cover Design: asp & Cover Image ber Front ry P i • Two-page lessons break big topics into bite-sized modules ® ISBN:978-1-118-76819-8 • Succinct explanations walk you through step by step 52999 • Full-color screen shots demonstrate each task • Helpful sidebars offer practical tips and tricks 9 781118768198 Computers/ W System Architecture/General e Richard Wentk n www.wiley.com/go/tyvraspberrypi $29.99 USA • $35.99 CAN • £21.99 UK tk Raspberry Pi ® Richard Wentk Teach Yourself VISUALLY™ Raspberry Pi® LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT Published by TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK John Wiley & Sons, Inc. AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT 10475 Crosspoint Boulevard LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO Indianapolis, IN 46256 WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL www.wiley.com MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY Published simultaneously in Canada NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN Copyright © 2014 by John Wiley & Sons, Inc., Indianapolis, Indiana RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES. IF No part of this publication may be reproduced, stored in a retrieval PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT system or transmitted in any form or by any means, electronic, mechani- PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER cal, photocopying, recording, scanning or otherwise, except as permit- NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. ted under Sections 107 or 108 of the 1976 United States Copyright THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN Act, without either the prior written permission of the Publisher, or THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER authorization through payment of the appropriate per-copy fee to the INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY 978-750-8400, fax 978-646-8600. Requests to the Publisher for permis- PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS sion should be addressed to the Permissions Department, John Wiley SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK & Sons, Inc., 111 River Street, Hoboken, NJ 07030, 201-748-6011, fax MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS 201-748-6008, or online at www.wiley.com/go/permissions. WRITTEN AND WHEN IT IS READ. Wiley publishes in a variety of print and electronic formats and by print- FOR PURPOSES OF ILLUSTRATING THE CONCEPTS AND TECHNIQUES on-demand. Some material included with standard print versions of this DESCRIBED IN THIS BOOK, THE AUTHOR HAS CREATED VARIOUS NAMES, book may not be included in e-books or in print-on-demand. If this book COMPANY NAMES, MAILING, E-MAIL AND INTERNET ADDRESSES, PHONE refers to media such as a CD or DVD that is not included in the version you AND FAX NUMBERS AND SIMILAR INFORMATION, ALL OF WHICH ARE purchased, you may download this material at http://booksupport.wiley FICTITIOUS. ANY RESEMBLANCE OF THESE FICTITIOUS NAMES, ADDRESSES, .com. For more information about Wiley products, visit www.wiley.com. PHONE AND FAX NUMBERS AND SIMILAR INFORMATION TO ANY ACTUAL PERSON, COMPANY AND/OR ORGANIZATION IS UNINTENTIONAL AND Library of Congress Control Number: 2013954228 PURELY COINCIDENTAL. ISBN: 978-1-118-76819-8 Manufactured in the United States of America Contact Us 10 9 8 7 6 5 4 3 2 1 For general information on our other products and services please con- tact our Customer Care Department within the U.S. at 877-762-2974, Trademark Acknowledgments outside the U.S. at 317-572-3993 or fax 317-572-4002. Wiley, Visual, the Visual logo, Teach Yourself VISUALLY, Read Less - For technical support please visit www.wiley.com/techsupport. Learn More and related trade dress are trademarks or registered trade- marks of John Wiley & Sons, Inc. and/or its affiliates. Raspberry Pi is a registered trademark of the Raspberry Pi Foundation in the United Kingdom and other countries. All other trademarks are the property of their respective owners. John Wiley & Sons, Inc. is not associated with any product or vendor mentioned in this book. Sales | Contact Wiley at (877) 762-2974 or fax (317) 572-4002. Credits Acquisitions Editor Director, Content Development Aaron Black & Assembly Robyn Siesky Sr. Project Editor Sarah Hellert Vice President and Executive Group Publisher Technical Editor Richard Swadley Paul Hallett Copy Editor Kim Heusel About the Author Richard Wentk has been building, working with, and writing about technology since the 1980s. He has had a lot of fun installing Raspberry Pi boards around his home for music storage, remote heating control and efficiency, and security. He is also an app developer and the author of a number of books for developers and Mac users. For the latest news and information, visit his site at www.zettaboom.com. Author’s Acknowledgments All books are a collaboration, and this one is no exception. I’d like to thank Aaron Black for giving the green light to this project, Paul Hallet for checking code and facts, and Sarah Hellert for making the transition from copy to print as smooth as possible. Extra special thanks are due to Annette Saunders for cake. How to Use This Book Who This Book Is For 3 Icons and Buttons This book is for the reader who has never used this Icons and buttons show you exactly what you need to particular technology or software application. It is click to perform a step. also for readers who want to expand their knowledge. 4 Tips The Conventions in This Book Tips offer additional information, including warnings and shortcuts. 1 Steps 5 Bold This book uses a step-by-step format to guide you Bold type shows command names, options, and text easily through each task. Numbered steps are actions or numbers you must type. you must do; bulleted steps clarify a point, step, or optional feature; and indented steps give you the 6 Italics result. Italic type introduces and defines a new term. 2 Notes Notes give additional information — special conditions that may occur during an operation, a situation that you want to avoid, or a cross reference to a related area of the book. CHAPTER 14 Control an LED with a Button Adding Custom Hardware You can breadboard a simple circuit around the Pi to control an LED with a button or switch. 7 Place the switch into the breadboard Both components connect to the Pi’s GPIO (general-purpose input output) pins. To light an LED, so that the two switch connectors are connect a GPIO pin to the LED, to a small resistor (220R to 470R) next, and finally to GND. over the break in the board. To use a switch, connect one end directly to GND. Connect the other end to a GPIO pin. You must 8 Connect pin 13 to the top of the switch. 6add a pull-up resistor that “pulls” the pin to 3V3 — that is, logic one, when it is not connected to 9 Connect pin 13 to the 3V3 power line anything. Use a medium (4k7 to 10k) resistor. via a 4k7 resistor. Note: You can use any resistor from 4k7 Control an LED with a Button to 10k. Note: You can find the code used in this 10 Connect the other end of the switch section on this book’s website, www. directly to 0V. wiley.com/go/tyvraspberrypi. Note: Use a male-to-male jumper lead. Note: These steps assume you have a If you do not have one, cut the leg off a breadboard with power lines on at least resistor and use that. foenme aslied eju, manpde ra l ecaodllse.ction of male-to- 11 Launch the desktop and IDLE. Note: On a breadboard, the holes are 12 Tay fiplee tchael lecodd LeE Dsh.poyw.n, and save it to joined horizontally, except for the power ljioniense do nv eerittihcaelrl yo.r both sides, which are 13 LOpEeDn. LpXyT,e ramnidn aplr,e tsysp e sud.o pyth3on 1 1 Caot nthnee cfta rp ilnef 1t —(3V t3o) o—ne tphoew loerw leirn ep.in Tswheit cLhE.D lights when you push the 2 Cfroonmn etchte pleinft 6 o (nG tNhDe) t—op trhoew t—hir dto p in Nsuotdeo: .Y Yoouu m cuanstn orutn r utnh ei tc fordoem a IsD rLoEo.t with another line. Note: Press , type C exit(), and 2 Note: Use the diagram at www.modmypi. press to quit Python. com/blog/raspberry-pi-gpio-cheat-sheet as a reference. 3 Cborenandebcota prdin. 11 to a line on the TIPS 4 Plug the long leg of the LED into the Can I use any LED? My circuit does not work. What did I do wrong? 5 same line. There are hundreds of LEDs in every color. High- A common mistake is using the wrong GPIO pins. 5 Ploluwge rt hlien es.hort leg of the LED into a blirgihgth.t nAe sstsa LnEdDasrd a LreE D“ twunilel dw”o trok ,p broudt uitc em baryi gnhotte rb e as Dafotuebr lset-ecph e2c.k N uesxitn,g c thheec ko nthliante tdhiea gLrEaDm i sm tehnet icoonreredc t 4 bright. For more light, use a smaller resistor. Keep it way around. Finally, check that you connected the 6 Join that line to the GND power line bigger than 220R to avoid burning out the LED or LED to GND and not 3V3, and that the order of through a 330R resistor. your Pi. components is Pin, LED, Resistor, and GND. 278 279 Table of Contents Chapter 1 Getting Started with Raspberry Pi Introducing Raspberry Pi ...........................................4 Take a Tour of Raspberry Pi .......................................5 Choose Accessories ..................................................6 Choose and Use a Case .............................................8 Connect a Monitor ................................................. 10 Connect USB Accessories ......................................... 12 Connect Power and Boot ......................................... 14 Chapter 2 Selecting an Operating System Understanding OS Options ....................................... 18 Prepare an SD Card ................................................. 20 Copy NOOBS to an SD card ....................................... 22 Select and Install Raspbian Wheezy .......................... 24 Back Up an SD Card ................................................ 26 Get Started with BerryBoot ...................................... 28 Chapter 3 Setting Up Raspbian Set a Password ...................................................... 32 Select a Keyboard Layout ........................................ 34 Select a Time Zone ................................................. 36 Manage Memory and SD Card Options ........................ 38 Set Up Overclocking ............................................... 40 Connect to the Internet .......................................... 42 Revise the Configuration ......................................... 43 Update the Operating System .................................. 44 Launch the Desktop ............................................... 46 Shut Down the Pi ................................................... 47 Chapter 4 Working with Applications Introducing Raspberry Pi Apps ................................. 50 Set Up Wi-Fi .......................................................... 52 View Web Pages ..................................................... 54 Work with Files in File Manager ................................ 56 Edit Text with Leafpad ............................................ 58 Configure the Desktop ............................................ 60 Configure the Launch Panel ..................................... 62 Table of Contents Chapter 5 Working with the Command Line Introducing Linux .................................................. 66 Using the Command Line ........................................ 68 Become the Superuser ............................................ 69 Understanding the File System ................................. 70 Navigate and List Directories ................................... 72 Create a Directory .................................................. 74 Delete Files and Directories ..................................... 75 View a File ............................................................ 76 Find a File or Command .......................................... 77 Copy, Move, and Rename Files ................................. 78 Work with File Permissions ...................................... 80 Using the Command Line History .............................. 82 Chapter 6 Understanding Advanced Commands Understanding Advanced Linux ................................ 86 Using the Nano Editor ............................................ 88 Set Up Autologin ................................................... 90 Download and Install Applications ........................... 92 Configure an Application ......................................... 94 Redirect Screen Output to a File ............................... 96 Combine Commands with a Pipe ............................... 97 Process Text with grep and sed ................................ 98 Create a Simple Script ...........................................100 Run a Command at Set Times ..................................102

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.