make_getting_started_with_sensors.pdf

(34329 KB) Pobierz
Make:
Getting
Started with
Sensors
Measure the World with Electronics,
Arduino, and Raspberry Pi
Kimmo Karvinen & Tero Karvinen
Sensors/ DIY Projects
Getting Started with Sensors
Sensors surround us. The world is full of them: infrared sensors in
motion detectors, carbon monoxide detectors in homes—even
tiny accelerometers, GPS modules, and cameras inside your
smartphone. Thanks to the proliferation of mobile devices,
sensors are now remarkably affordable, meaning you can
combine inexpensive sensors and microcontroller boards to
make your own devices.
This fully-illustrated, hands-on book teaches you to connect and
read sensors through a series of short projects. You’ll learn to use
the immensely popular Arduino and Raspberry Pi boards to
process data through simple programs you develop.
In
Getting Started with Sensors,
you’ll write programs and
build devices that respond to:
»
Rotation with a potentiometer
»
Distance with ultrasound
»
Proximity with infrared
»
Light and dark with a photoresistor
»
Temperature with a thermometer
»
Magnetic fields with a H all effect sensor
You’ll also work with resistive and electromechanical sensors, as
well as switches, transducers, potentiometers, buzzers, 555
timers, and voltage dividers.
There’s a whole world out there full of sensory impressions you
can control, track, and manage.
How will you capture it?
For more sensor projects, check out the authors’ other
books:
Make: Arduino Bots and Gadgets
and
Make: Sensors.
US $19.99 CAN $20.99
ISBN: 978-1-4493-6708-4
Make:
makezine.com
Getting
Started with
Sensors
Kimmo Karvinen and
Tero Karvinen
Getting Started with Sensors
by Kimmo Karvinen and Tero Karvinen
Copyright © 2014 Tero Karvinen, Kimmo Karvinen. All rights reserved.
Printed in the United States of America.
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 promo-
tional use. Online editions are also available for most titles (http:/
/safaribookson-
line.com).
For more information, contact O’Reilly Media’s institutional sales depart-
ment: 800-998-9938 or
corporate@oreilly.com.
Editors:
Brian Jepson, David Scheltema, and Emma Dvorak
Production Editor:
Nicole Shelby
Copyeditor:
Sonia Saruba
Technical Editor:
Philipp Marek
Proofreader:
Jasmine Kwityn
Cover Designer:
Brian Jepson
Interior Designer:
Nellie McKesson
Illustrator:
Kimmo Karvinen
Photographer:
Kimmo Karvinen
Cover Art:
Kimmo Karvinen
Technical Advisor:
Paavo Leinonen
August 2014:
First Edition
Revision History for the First Edition
2014-08-06: First Release
2016-07-27: Second Release
See
http:/
/oreilly.com/catalog/errata.csp?isbn=9781449367084
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: Getting Started with
Sensors
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-449-36708-4
[LSI]
Contents
Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
1/Sensors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1
Project 1: Photoresistor to Measure Light.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Parts.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Build It.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Discussion: Photoresistors.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Interactive Sensor Control.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Going Forward.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2/Basic Sensors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9
Project 2: A Simple Switch.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Parts.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Build It.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Troubleshooting.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
An LED Needs a Resistor.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Project 3: Buzzer Volume Control.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Parts.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Build It.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Troubleshooting.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Project 4: Hall Effect.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Parts.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Build It.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Troubleshooting.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Project 5: Firefly.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Integrated Circuits.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
555 Timer IC.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Light Up an LED When It’s Bright.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Light to Darkness.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Transistors.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Fading an LED.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
555 Fading Blink.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
iii
Zgłoś jeśli naruszono regulamin