make_raspberry_pi_and_avr_projects.pdf

(51681 KB) Pobierz
Make:
Raspberry Pi
and
AVR Projects
Augment Your Pi With Analog ICs and
the Chip That Powers Arduino
Cefn Hoile, Clare Bowman, Sjoerd Dirk Meijer,
Brian Corteil & Lauren Orsini
Hardware/Programming
Make:
Raspberry Pi and
AVR Projects
What brings fish, music, fruit, and giraffes together? Raspberry Pi!
The four projects in
Make: Raspberry Pi and AVR Projects
explore
music, light, home automation, and the Internet of Things—made
with a combination of the Raspberry Pi, the AVR chip that powers
Arduino, and other components.
Perfect for intermediate Raspberry Pi hackers, all the projects in
this book are keyed to Raspberry Pi’s newest iteration: the model
B+. Compiled in a very personal way by five international makers,
this book takes you through the steps, concepts, and pointers you
need to make your own inspired creations.
If you’ve already learned the basics of the Raspberry Pi and are
ready to take your knowledge to the next level, then you’re ready
for the fun new challenges outlined in this book.
Using sensors, Scratch, web servers, and web services, you’ll
learn to make:
»
»
»
»
Picussion: A wearable sound sample player triggered by
knock sensors
Raspberries from Scratch: Turn anything—including real
raspberries—into a keyboard that controls a Scratch project
The Internet of Fish: Let your Pi text you when your fish tank
or swimming pool hits a certain temperature
Giraffe Mood Lamp: This light fixture changes color based on
the Twitter messages it receives
You’ve got 8-bit in my 32-bit and it tastes great!
US $24.99 CAN $26.99
ISBN: 978-1-4571-8624-0
Make:
makezine.com
Make:
Raspberry Pi
and AVR
Projects
Cefn Hoile, Clare Bowman,
Sjoerd Dirk Meijer,
Brian Corteil, Lauren Orsini
Make: Raspberry Pi and AVR Projects
by Cefn Hoile, Clare Bowman, Sjoerd Dirk Meijer, Brian Corteil, and Lauren Orsini
Copyright © 2015 Backstop Media, LLC. 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 promo-
tional use. Online editions are also available for most titles (http:/
/safaribookson-
line.com).
For more information, contact our corporate/institutional sales depart-
ment: 800-998-9938 or
corporate@oreilly.com.
Editor:
Patrick Di Justo
Production Editor:
Melanie Yarbrough
Copyeditor:
Charles Roumeliotis
Proofreader:
Kim Cofer
Indexer:
Angela Howard
Interior Designer:
David Futato
Cover Designer:
Brian Jepson
Illustrators:
Cefn Hoile, Clare Bowman, Sjoerd Dirk Meijer, Brian Corteil, and
Cover Photographer:
Sjoerd Dirk Meijer
November 2014:
First Edition
Rebecca Demarest
Revision History for the First Edition
2014-11-04: First Release
See
http:/
/oreilly.com/catalog/errata.csp?isbn=9781457186240
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.
Make: Raspberry Pi and AVR
Projects
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 result-
ing from the use of the information contained herein.
978-1-457-18624-0
[LSI]
Contents
Preface.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
1.
Introduction.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
The Power of the Pi.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Raspbian.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Who Is This Book For?.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Projects in This Book.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1
1
2
2
2
2.
Picussion.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Materials and Tools.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Solderless Breadboarding Materials.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Solderless Breadboard Tools.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Soldering Materials.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Soldering Tools.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Configuring Your Raspberry Pi.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Exercise 1: Blink.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Attaching the UART.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Testing with the Blink Sketch.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Troubleshooting.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Exercise 2: Knock.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Loading the Knock Sketch.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Displaying Knock Messages in the Python Shell.
. . . . . . . . . . . . . . . 26
Loading a Python Script to Display Knock! Messages.
. . . . . . . . 28
Exercise 3: Sending Knock Messages Wirelessly.
. . . . . . . . . . . . . . . . . 29
Using Bluetooth for Programming.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Transmitting Wireless Messages.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Triggering Audio.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Troubleshooting Audio from the Pi.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
iii
Zgłoś jeśli naruszono regulamin