make_action_movement_live_and_sound.pdf

(143153 KB) Pobierz
Make:
Action
Movement, Light, and Sound with
Arduino and Raspberry Pi
Simon Monk
Technology & Engineering / Robotics
Make:
Action
Beginning with the basics and moving gradually to greater challenges, this
book takes you step-by-step through experiments and projects that show
you how to make your Arduino or Raspberry Pi create and control movement,
light, and sound. In other words: action!
The Arduino is a simple microcontroller with an easy-to-learn programming
environment, while the Raspberry Pi is a tiny Linux-based computer. This
book clearly explains the differences between the Arduino and Raspberry Pi,
when to use them, and to which purposes each are best suited.
Using these widely available and inexpensive platforms, you'll learn to control
LEDs, motors of various types, solenoids, AC (alternating current) devices,
heaters, coolers, displays, and sound. You’ll even discover how to monitor
and control these devices over the Internet. Working with solderless
breadboards, you’ll get up and running quickly, learning how to make projects
that are as fun as they are informative.
In
Make: Action,
you'll learn to:
»
»
»
»
»
»
»
Build a can crusher using a linear actuator with your Arduino
Have an Arduino water your plants
Build a personal traffic signal using LEDs
Make a random balloon popper with Arduino
Cool down your beverages with a thermostatic drink cooler you build yourself
Understand and use the PID control algorithm
Use Raspberry Pi to create a puppet dance party that moves to your tweets!
Learn how to control mechanisms and systems, and then jump into the
Internet of Things (IoT) to connect with today's newest technology.
Hello, World? Hello,
Universe!
US $34.99 CAN $40.99
ISBN: 978-1-4571-8779-7
Make: Action
Movement, Light, and Sound with
Arduino and Raspberry Pi
Simon Monk
Make: Action
by Simon Monk
Copyright © 2016 Simon Monk. All rights reserved.
Printed in Canada.
Published by Maker Media, Inc., 1160 Battery Street East, Suite 125, San Francisco, CA 94111.
Maker Media books may be purchased for educational, business, or sales promotional use. Online edi-
tions are also available for most titles (http:/
/safaribooksonline.com).
For more information, contact
O’Reilly Media’s institutional sales department: 800-998-9938 or
corporate@oreilly.com.
Editor:
Roger Stewart
Production Editor:
Nicole Shelby
Technical Reviewer:
Duncan Amos
Copyeditor:
Jasmine Kwityn
Proofreader:
Kim Cofer
Indexer:
Ellen Troutman
Interior Designer:
David Futato
Cover Designer:
Karen Montgomery
Illustrator:
Rebecca Demarest
January 2016:
First Edition
Revision History for the First Edition
2016-02-02: First Release
2016-07-29: Second Release
See
http:/
/oreilly.com/catalog/errata.csp?isbn=9781457187797
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: Action
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 informa-
tion contained herein.
978-1-457-18779-7
[TC]
Table of Contents
1.
Introduction
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Arduino and Pi
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Raspberry Pi
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Arduino
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Choosing a Device: Arduino or Pi?
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Alternatives
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Summary
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.
Arduino
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
What Is an Arduino?
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Installing the Arduino IDE
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Uploading a Sketch
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
The Book Code
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Programming Guide
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Setup and Loop
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Variables
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Digital Outputs
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Digital Inputs
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Analog Inputs
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Analog Outputs
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
iii
Zgłoś jeśli naruszono regulamin