Transcription of T Practical Arduino - interorganic.com.ar
1 This book was written to demonstrate a variety of Arduino techniques in a Practical context, giving you an opportunity to learn how the theory and reference material already available online applies to real-world projects. If you ve come as far as picking up a whole book about Arduino , you re ready for something more substantial than assembly instructions. You don t want a simple series of steps to follow: you want to understand not just how to assemble something, but why it was designed that way in the first place. That s what this book will give you: you won t just be a color-by-numbers painter; you ll learn to be a true hardware craftsman and artist, able to conceptualize, design, and assemble your own creations. We want you to take these projects as inspiration and examples of applying a variety of handy techniques and then adapt them to suit your own requirements, coming up with inspiration and new ideas that put ours to shame. And we hope that you ll then share your creations with us and with the world, inspiring others in turn.
2 By following through the projects in this book, you will gain a number of insights into the flexibility of Arduino as a platform for taking software and hardware and linking them to the physical world around Oxer Hugh BlemingsPractical Arduino Cool Projects for Open Source HardwareOxerBlemingsTECHNOLOGY IN ACTION this print for content only size & color not accuratetrim size = " x " spine = " 448 page count CYAN MAGENTA YELLOW BLACK PANTONE 123 CPractical $ in HardwareUser level: Beginning AdvancedISBN 978-1-4302-2477-8978143022477853999 Practical ArduinoCool Projects for Open Source HardwareSOURCE CODE ONLINELEARN IN-DEPTH Arduino TECHNIQUES USING REAL-WORLD PROJECTSAlso available: Practical Arduino Cool Projects for Open Source Hardware Jonathan Oxer Hugh Blemings Practical Arduino : Cool Projects for Open Source Hardware Copyright 2009 by Jonathan Oxer and Hugh Blemings All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher.
3 ISBN-13 (pbk): 978-1-4302-2477-8 ISBN-13 (electronic): 978-1-4302-2478-5 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Cover picture of Arduino Duemilanove used with permission of SparkFun Electronics. President and Publisher: Paul Manning Lead Editor: Michelle Lowman Technical Reviewers: Nathan Seidle, Andy Gelme, Thomas Sprinkmeier, Trent Lloyd, Scott Penrose, Marc Alexander, Philip Lindsay Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie, Duncan Parkes, Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Coordinating Editor: Jim Markham Copy Editor: Vanessa Moore Compositor: Bytheway Publishing Services Indexer: Julie Grady Artist: April Milne Cover Designer: Kurt Krames Distributed to the book trade worldwide by Springer-Verlag New York, Inc.
4 , 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail or visit For information on translations, please contact Apress directly at 2855 Telegraph Avenue, Suite 600, Berkeley, CA 94705. Phone 510-549-5930, fax 510-549-5939, e-mail or visit Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales eBook Licensing web page at The information in this book is distributed on an as is basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at For everyone who looks at the everyday objects around them and sees the potential of what they could Contents at a Glance Contents at a Glance.
5 Iv v About the xvi About the Technical Reviewers .. xvii Acknowledgments .. xix Introduction .. xx Chapter 1: 1 Chapter 2: Appliance Remote 17 Chapter 3: Time-Lapse Camera 37 Chapter 4: Virtual USB Keyboard .. 51 Chapter 5: PS/2 Keyboard or Mouse Input .. 63 Chapter 6: Security/Automation Sensors .. 81 Chapter 7: Online 101 Chapter 8: Touch Control Panel .. 121 Chapter 9: Speech Synthesizer .. 139 Chapter 10: Water Flow Gauge .. 163 Chapter 11: Oscilloscope/Logic Analyzer .. 185 Chapter 12: Water Tank Depth 209 Chapter 13: Weather Station 239 Chapter 14: RFID Access Control System .. 269 Chapter 15: Vehicle Telemetry Platform .. 295 Chapter 16: 383 Index .. 405 iv Contents Contents at a Glance .. iv v About the Authors .. xvi About the Technical Reviewers .. xvii Acknowledgments .. xix Introduction .. xx Chapter 1: 1 Fundamentals ..1 Sharing Your Work .. 1 Practical Electronics for Software Developers.
6 1 Current, Voltage, and 2 Mains Is Nasty .. 2 Reading Schematics .. 3 Resistance and Resistors .. 6 Ohm s Law and Current Limiting .. 7 Choosing 8 8 Power 9 USB 9 Batteries .. 10 Wall 11 v CONTENTS Capacitance and Capacitors .. 11 Fundamentals .. 11 Capacitor Types .. 12 Power Supply Bypass .. 13 ESD Precautions .. 13 Tools .. 13 Parts .. 14 Further Reading .. 15 Chapter 2: Appliance Remote 17 Parts Required .. 17 Instructions .. 19 Test and Investigate Appliance Remote .. 19 Assemble Reed Relay Shield .. 21 Connect Reed Relay Shield to Remote Control .. 25 Create Reed Relay Control Program .. 27 ApplianceRemoteControl .. 27 ApplianceRemoteControlCompact .. 30 Test Reed Relay Shield and Sketch .. 32 34 Wireless Link .. 34 Automatic Trigger .. 34 Socket Connections .. 35 Chapter 3: Time-Lapse Camera 37 Parts Required .. 37 Instructions .. 39 Assemble Prototyping 39 Connect Camera Shutter 39 Remote Shutter Release 40 vi CONTENTS Infrared Remote Control.
7 42 Modify Camera .. 43 Configure 44 Calculate Photo 44 Configure and Load Sketch .. 44 Check Memory Capacity .. 48 Set Up Your 48 Process the Images .. 48 Linux .. 48 Windows .. 48 Macintosh .. 49 49 Chapter 4: Virtual USB Keyboard .. 51 Parts Required .. 51 Instructions .. 53 Populate Prototyping Shield .. 53 Prepare the UsbKeyboard 56 Compile and Upload 57 61 Chording Keyboard .. 61 Chapter 5: PS/2 Keyboard or Mouse Input .. 63 Parts Required .. 63 Instructions .. 64 PS/2 Connections .. 65 Recycled 6-Pin Mini-DIN Sockets .. 66 6-Pin Mini-DIN Panel Sockets .. 67 PS/2 Extension 69 Keyboard Software .. 73 vii CONTENTS Mouse Software .. 76 79 Barcode Reader for a Stock Control System .. 79 Resources .. 80 Chapter 6: Security/Automation Sensors .. 81 Parts Required .. 82 Instructions .. 84 Security Sensor 84 Assemble Four-Channel Alarm Sensor Shield .. 87 Install End-of-Line Resistors on Sensor .. 92 Load Test Program .. 95 PIR Placement .. 98 98 Visual Display Written in Processing.
8 98 Home Security System .. 99 Multiple Buttons on One Input .. 99 Chapter 7: Online 101 Parts Required .. 101 Instructions .. 103 Mount PCB Plugs on Shield .. 103 Connect Data 105 Assemble Sensors .. 106 Load Program .. 108 119 Chapter 8: Touch Control Panel .. 121 Parts Required .. 122 Instructions .. 123 How Resistive Touch Screens Work .. 123 viii CONTENTS Basic Touch Screen Connection Test .. 126 Arduino TouchScreen Library .. 128 Controlling a Processing 128 Construct Hardware for Home Automation Control Panel .. 131 Calibrate Hot Zones .. 134 Mount Arduino .. 137 Chapter 9: Speech Synthesizer .. 139 Parts Required .. 140 Instructions .. 142 Speech Output Signal .. 142 Beginning Assembly .. 143 SpeakJet PWM "Audio" Output .. 144 Quick 145 Fit Status 145 Making a Line-Level Output 148 On-Board Amplifier .. 149 Speech Synthesizer 151 Create Your Own 153 160 Read SpeakJet Status .. 160 Resources .. 161 Chapter 10: Water Flow Gauge .. 163 Parts Required.
9 164 Instructions .. 165 Replace Sensor Connector .. 165 Prepare Prototyping 166 Prepare LCD Module .. 168 Fit LCD to Case .. 171 ix CONTENTS Fit Arduino in Case .. 173 Determine Scaling Factor .. 174 Configure, Compile, and Test Sketch .. 175 Hardware Interrupts .. 175 Volatile Variables .. 176 Flow Gauge 178 Install Flow Sensor .. 183 184 Online 184 Multiple 184 Resources .. 184 Chapter 11: Oscilloscope/Logic Analyzer .. 185 Parts Required .. 187 Instructions .. 189 Assemble the Case .. 190 Fit the Prototyping Shield .. 193 Make Test Probes .. 194 How Successive Approximation ADC 194 Connection to Circuit under Test .. 197 Install Software in Arduino .. 198 Analog Read 198 Digital Read Version .. 200 Digital Read Sketch with Optimized Communications Format .. 202 Install Processing and Run Visualization Program ..203 205 Input Voltage Prescaler .. 205 206 x CONTENTS Chapter 12: Water Tank Depth 209 Parts Required .. 210 Instructions .. 212 Assemble the Shield.
10 213 Determine Sensor Installation Method .. 215 Assemble the Sensor 219 Assemble the Arduino 223 Install the WiShield Library and Driver .. 226 Load the Tank-Level Sketch .. 227 Prettier Web Interface .. 231 Calibrating the Empty Tank Level .. 234 Install the Sensor and Arduino .. 235 Calibrating the Full Tank 236 236 Upload Data to Pachube .. 236 Control Pumps or Irrigation .. 236 Local Level Display .. 237 Reading Multiple Tanks .. 237 Chapter 13: Weather Station 239 Parts Required .. 241 Instructions .. 243 Test and Install the Weather Station .. 243 Understanding the 243 Assemble the Receiver Shield .. 246 Weather Station Receiver Program .. 250 Twitter Weather Updates .. 265 267 Private Online Weather 267 xi CONTENTS Chapter 14: RFID Access Control System .. 269 Parts Required .. 272 Instructions .. 274 Assemble the Prototyping 275 Power 275 RFID Serial Connection .. 277 Relay Output .. 278 Indicator 280 Manual Release 282 Assemble the ID-12 Reader Module.