make_getting_started_with_raspberry_pi_2nd_edition.pdf

(34363 KB) Pobierz
Make:
Getting
Started with
Raspberry Pi
2nd Edition
Getting to Know the Inexpensive
ARM-powered Linux Computer
Matt Richardson & Shawn Wallace
Electronics/Programming
Getting Started with
Raspberry Pi
What can you do with the Raspberry Pi, the affordable computer
the size of a credit card? All sorts of things! If you’re learning how
to program—or looking to build new electronic projects, this
hands-on guide will show you just how valuable this flexible little
platform can be.
Updated to include coverage of the Raspberry Pi Model B+,
Getting Started with Raspberry Pi
takes you step-by-step through
many fun and educational possibilities. Take advantage of several
preloaded programming languages. Use the Raspberry Pi with
Arduino. Create Internet-connected projects. Play with multimedia.
With Raspberry Pi, you can do all of this and more.
In
Getting Started with Raspberry Pi,
you’ll:
»
Get acquainted with hardware features on the Pi’s board
»
Learn enough Linux to move around the operating system
»
Start programming in Python and Scratch
»
Draw graphics, play sounds, and handle mouse events with Pygame
»
Use the Pi’s input and output pins to do some hardware hacking
»
Discover how Arduino and the Raspberry Pi can work together
»
Create your own Pi-based web server with Python
»
Work with the Raspberry Pi Camera Module and USB webcams
Hack Hardware With Software!
US $19.99 CAN $20.99
ISBN: 978-1-4571-8612-7
Make:
makezine.com
Getting
Started with
Raspberry Pi
Matt Richardson
and Shawn Wallace
SECOND EDITION
Getting Started with Raspberry Pi
by Matt Richardson and Shawn Wallace
Copyright © 2015 Matt Richardson and Shawn Wallace. All rights reserved.
Printed in the United States of America.
Published by Maker Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
Maker Media books may be purchased for educational, business, or sales promotional use.
Online editions are also available for most titles (http:/
/safaribooksonline.com).
For more
information, contact our distributor’s corporate/institutional sales department:
800-998-9938 or
corporate@oreilly.com.
Editor:
Brian Jepson
Production Editor:
Melanie Yarbrough
Copyeditor:
Jasmine Kwityn
Proofreader:
Amanda Kersey
Indexer:
WordCo Indexing Services
Interior Designer:
Ron Bilodeau and Nellie McKesson
Cover Designer:
Brian Jepson
Illustrator:
Marc de Vinck
December 2012:
October 2014:
First Edition
Second Edition
Revision History for the Second Edition:
2014-10-13: First Release
See
http:/
/oreilly.com/catalog/errata.csp?isbn=9781457186127
for release details.
Make:, Maker Shed, and Maker Faire are registered trademarks of Maker Media, Inc. The
Maker Media logo is a trademark of Maker Media, Inc.
Getting Started with Raspberry Pi
and related trade dress are trademarks of Maker Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products
are claimed as trademarks. Where those designations appear in this book, and Maker
Media, Inc. was aware of a trademark claim, the designations have been printed in caps or
initial caps.
While every precaution has been taken in the preparation of this book, the publisher and
authors assume no responsibility for errors or omissions, or for damages resulting from
the use of the information contained herein.
978-1-457-18612-7
[LSI]
Contents
Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
1/Getting Up and Running. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
A Tour of the Boards.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
The Proper Peripherals.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7
The Case.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Choose Your Distribution.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Flash the SD Card.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
For Advanced Users: Create Your Own Disk Image.
. . . . . . . . . . . . . . . . . . 13
Booting Up.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
14
Configuring Your Pi.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Shutting Down.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Running Headless.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Troubleshooting.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Going Further.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2/Getting Around Linux on the Raspberry Pi. . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Using the Command Line.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Files and the Filesystem.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
More Linux Commands.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
28
Processes.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Sudo and Permissions.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
The Network.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
/etc.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Setting the Date and Time.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Installing New Software.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Sound in Linux.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Upgrading Your Firmware.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
35
36
Going Further.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3/Specialized Distributions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Distributions for Home Theater.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Distributions for Music.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
iii
Zgłoś jeśli naruszono regulamin