1. Trang chủ
  2. » Công Nghệ Thông Tin

arduino in action

370 807 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

MANNING IN ACTION Martin Evans Joshua Noble Jordan Hochenbaum www.it-ebooks.info Arduino in Action www.it-ebooks.info www.it-ebooks.info Arduino in Action MARTIN EVANS JOSHUA NOBLE JORDAN HOCHENBAUM MANNING S HELTER I SLAND www.it-ebooks.info For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact Special Sales Department Manning Publications Co. 20 Baldwin Road PO Box 261 Shelter Island, NY 11964 Email: orders@manning.com ©2013 by Manning Publications Co. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Photographs in this book were created by Martin Evans and Jordan Hochenbaum, unless otherwise noted. Illustrations were created by Martin Evans, Joshua Noble, and Jordan Hochenbaum. Fritzing (fritzing.org) was used to create some of the circuit diagrams. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps. Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine. Manning Publications Co. Development editor: Cynthia Kane 20 Baldwin Road Copyeditor: Andy Carroll PO Box 261 Proofreader: Katie Tennant Shelter Island, NY 11964 Typesetter: Dennis Dalinnik Cover designer: Marija Tudor ISBN: 9781617290244 Printed in the United States of America 1 2 3 4 5 6 7 8 9 10 – MAL – 19 18 17 16 15 14 13 www.it-ebooks.info v brief contents P ART 1 G ETTING STARTED . 1 1 ■ Hello Arduino 3 2 ■ Digital input and output 21 3 ■ Simple projects: input and output 41 P ART 2 P UTTING A RDUINO TO WORK 59 4 ■ Extending Arduino 61 5 ■ Arduino in motion 81 6 ■ Object detection 114 7 ■ LCD displays 129 8 ■ Communications 152 9 ■ Game on 188 10 ■ Integrating the Arduino with iOS 216 11 ■ Making wearables 244 12 ■ Adding shields 261 13 ■ Software integration 278 www.it-ebooks.info www.it-ebooks.info vii contents preface xv acknowledgments xvii about this book xix about the cover illustration xxii P ART 1 G ETTING STARTED . 1 1 Hello Arduino 3 1.1 A brief history of the Arduino 4 1.2 The Arduino hardware 5 Arduino Uno 5 ■ Arduino Duemilanove 5 Arduino Ethernet 6 ■ Arduino Mega 6 Other Arduino boards 7 ■ Attack of the clones 8 Getting an Arduino 9 1.3 Setting up your working environment 10 Software for Arduino 10 ■ Basic hardware setup 10 Your Arduino toolbox 11 1.4 Make something happen! 11 Your first blinking LED 11 ■ Sketch to make an LED blink 12 Connecting everything 12 ■ Uploading and testing 13 www.it-ebooks.info CONTENTS viii 1.5 Touring the IDE 14 The main editor 14 ■ Serial monitor 15 ■ Catching errors 16 Process 16 1.6 Anatomy of a sketch 17 A routine called setup 17 ■ The endless loop 18 1.7 Commenting code 18 1.8 Summary 20 2 Digital input and output 21 2.1 Getting started 21 Using a breadboard 22 ■ Circuit diagram 22 Adding the LEDs 24 ■ Connecting the hardware 24 Sketch to flash five LEDs 25 ■ Upload and test 27 2.2 Gaining control 27 Circuit diagram 27 ■ Connections 28 Interrupts butting in 29 ■ Sketch to control the LEDs with a push button 30 ■ Upload and test 32 ■ Time for a break 32 Upload and test 33 2.3 Reaction tester 33 Circuit diagram 33 ■ Connections 33 ■ Sketch to test reaction speed 33 ■ Upload and test 36 2.4 Reactometer: Who really has the fastest reaction time? 37 Sketch to measure reaction speed 37 ■ Upload and test 38 2.5 Summary 39 3 Simple projects: input and output 41 3.1 Time to get analog 42 What’s the difference between analog and digital? 42 Reading a potentiometer 43 ■ Connecting the hardware 43 Sketch to read a potentiometer 44 ■ Upload and test 45 3.2 A piezoelectric transducer 46 The circuit diagram 47 ■ Connecting the hardware 48 Sketch to measure output from a piezoelectric transducer 49 Upload and test 51 ■ Circuit with added speaker 51 Connecting the hardware 51 ■ Sketch to generate a tone 53 Upload and test 53 www.it-ebooks.info CONTENTS ix 3.3 Making a pentatonic or five-tone keyboard 54 Circuit diagram 54 ■ Connecting the hardware 54 Sketch to create a pentatonic keyboard 56 ■ Upload and test 57 3.4 Summary 58 P ART 2 P UTTING A RDUINO TO WORK 59 4 Extending Arduino 61 4.1 Extending the Arduino with libraries 62 4.2 Core library 62 4.3 Standard libraries 63 Test-driven development with ArduinoTestSuite 63 Storing values using EEPROM 64 ■ Storing more data with SD 65 ■ Get connected with Ethernet 67 Serial communication with Firmata 68 ■ Displaying data using the LiquidCrystal library 69 ■ Controlling a servo motor 70 ■ Turning a stepper motor 70 Communicating with SPI peripherals 71 Communicating with the two-wire interface 72 Get more serial ports with SoftwareSerial 74 4.4 Contributed libraries 75 Installing a new library 76 4.5 Expanding the Arduino with shields 76 Common shields 77 ■ Gotchas: will it work with my Arduino? 80 4.6 Summary 80 5 Arduino in motion 81 5.1 Getting up to speed with DC motors 82 Stopping and starting 83 ■ Sketch to turn a small DC motor on and off 84 ■ Connecting the hardware 84 Upload and test 86 5.2 Speed control and reverse 87 PWM to the rescue 87 ■ The H-bridge for motor control 89 The L293D dual H driver 90 ■ Connecting the hardware 91 Sketch to control a motor with an L293D 92 Upload and test 93 ■ Changing motor speed 93 Upload and test 94 www.it-ebooks.info [...]... professor in Music Technology: Interaction, Intelligence, and Design at California Institute of the Arts in 2012, and the Arduino continues to be an important part of my artistic and academic practice My work with the Arduino has been featured online and in print, including in WIRED and Computer Arts magazine, and my current Arduino- based projects range from kinetic surfaces for live projection mapping and... extending or enhancing the Arduino hardware This chapter includes instructions for creating your own shields Finally, chapter 13 is on software integration, and it covers communicating with the Arduino from other software programs There are also several appendices Appendix A is about installing the Arduino software on Windows, Mac OS X, and Linux operating systems Appendix B is a coding primer for the Arduino. .. Chapter 3 builds on the knowledge gained in chapter 2 by looking at a couple of simple projects that use the Arduino inputs and outputs Part 2 of the book looks at the Arduino in more depth This is where we put the Arduino to work Chapter 4 covers software libraries that extend the Arduino s functionality Chapter 5 gets the Arduino into motion by showing how an Arduino can be used to control a range... The final connection 220 220 Creating a single-view application in Xcode 221 Writing the code 225 10.3 The Arduino gets involved 228 Sketch to switch LED from iOS device Testing the sketch 229 10.4 Doing more with Xcode Adding a Slider control 10.5 Arduino sliding 235 ■ Testing the circuit Moving data to the iOS device Xcode coding 237 Testing 243 10.7 230 230 Arduino slider circuit 236 10.6 Summary... Source code in listings and text is in a fixed-width font like this, to separate it from ordinary text, and code annotations accompany many of the listings You’ll find the source code for the examples in this book available from the publisher’s website at www.manning.com/ArduinoinAction Author Online The purchase of Arduino in Action includes free access to a private web forum run by Manning Publications,... discussion of the Arduino in general You’ll start by learning your way around the Arduino and its development environment and completing a tutorial that introduces you to your first project Then you’ll look at a couple of simple projects that use the Arduino inputs and outputs www.it-ebooks.info www.it-ebooks.info Hello Arduino This chapter covers ■ The history of the ArduinoArduino hardware ■ Hardware... We’re now going to look at the more commonly available Arduino models, starting with the Arduino Uno 1.2.1 Arduino Uno “Dinner is Served” was the blog title announcing on September 25, 2010, the arrival of the Arduino Uno (meaning one in Italian), and its bigger brother, the Mega2560 The Arduino Uno is pin-compatible with previous Arduinos, including the Duemilanove and its predecessor the Diecimila The... opening chapter out with a look at the Arduino integrated development environment (IDE) before making our first project: an LED that blinks on and off Let’s start by learning where the Arduino comes from 1.1 A brief history of the Arduino The Arduino got its start at the Interaction Design Institute in the city of Ivrea, Italy, in 2005 Professor Massimo Banzi was looking for a low-cost way to make it easier... to put the Arduino to work with a number of advanced techniques that you can use in your own projects Code for the sketches covered in each chapter is available online via the book’s website: www.manning.com/ArduinoinAction We suggest trying to follow along with the projects in the book as much as you can Typing in the individual code listings will help to fix concepts and ideas into your mind This book... the production of a number of clones or copies of Arduino, with many of the clone manufacturers taking the original specification and making their own changes The Arduino name is trademarked, preventing derivatives from using the Arduino name in their products unless permission is given by the Arduino team www.it-ebooks.info The Arduino hardware 9 SEEEDUINO (YES, 3 E’S) If you like the color red, this . MANNING IN ACTION Martin Evans Joshua Noble Jordan Hochenbaum www.it-ebooks.info Arduino in Action www.it-ebooks.info www.it-ebooks.info Arduino in Action MARTIN EVANS JOSHUA NOBLE JORDAN. STARTED . 1 1 Hello Arduino 3 1.1 A brief history of the Arduino 4 1.2 The Arduino hardware 5 Arduino Uno 5 ■ Arduino Duemilanove 5 Arduino Ethernet 6 ■ Arduino Mega 6 Other Arduino boards 7 ■ Attack. the Arduino has been featured online and in print, including in WIRED and Computer Arts magazine, and my current Arduino- based projects range from kinetic surfaces for live projection mapping

Ngày đăng: 05/05/2014, 12:56

Xem thêm: arduino in action

TỪ KHÓA LIÊN QUAN

Mục lục

    Code conventions and downloads

    about the cover illustration

    1.1 A brief history of the Arduino

    1.2.6 Attack of the clones

    1.3 Setting up your working environment

    1.4.1 Your first blinking LED

    1.4.2 Sketch to make an LED blink

    1.6 Anatomy of a sketch

    1.6.1 A routine called setup

    2 Digital input and output

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN