




























































































Estude fácil! Tem muito documento disponível na Docsity
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Prepare-se para as provas
Estude fácil! Tem muito documento disponível na Docsity
Prepare-se para as provas com trabalhos de outros alunos como você, aqui na Docsity
Encontra documentos específicos para os exames da tua universidade
Prepare-se com as videoaulas e exercícios resolvidos criados a partir da grade da sua Universidade
Responda perguntas de provas passadas e avalie sua preparação.
Ganhe pontos para baixar
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Projetos com Arduino
Tipologia: Manuais, Projetos, Pesquisas
1 / 208
Esta página não é visível na pré-visualização
Não perca as partes importantes!





























































































™
™
New York Chicago San Francisco Lisbon London Madrid Mexico City Milan New Delhi San Juan Seoul Singapore Sydney Toronto
Copyright © 2010 by The McGraw-Hill Companies, Inc. All rights reserved. Except as permitted under the United States Copyright Act of 1976, no part of this publication may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without the prior written permission of the publisher.
ISBN: 978-0-07-174134-
MHID: 0-07-174134-
The material in this eBook also appears in the print version of this title: ISBN: 978-0-07-174133-0, MHID: 0-07-174133-X.
All trademarks are trademarks of their respective owners. Rather than put a trademark symbol after every occurrence of a trademarked name, we use names in an editorial fashion only, and to the benefit of the trademark owner, with no intention of infringement of the trademark. Where such designa- tions appear in this book, they have been printed with initial caps.
McGraw-Hill eBooks are available at special quantity discounts to use as premiums and sales promotions, or for use in corporate training programs. To contact a representative please e-mail us at [email protected].
Trademarks: McGraw-Hill, the McGraw-Hill Publishing logo, Evil Genius™, and related trade dress are trademarks or registered trademarks of The McGraw-Hill companies and/or its affiliates in the United States and other countries and may not be used without written permission. All other trade- marks are the property of their respective owners. The McGraw-Hill Companies is not associated with any product or vendor mentioned in this book.
Information has been obtained by McGraw-Hill from sources believed to be reliable. However, because of the possibility of human or mechanical error by our sources, McGraw-Hill, or others, McGraw-Hill does not guarantee the accuracy, adequacy, or completeness of any information and is not responsible for any errors or omissions or the results obtained from the use of such information.
TERMS OF USE
This is a copyrighted work and The McGraw-Hill Companies, Inc. (“McGrawHill”) and its licensors reserve all rights in and to the work. Use of this work is subject to these terms. Except as permitted under the Copyright Act of 1976 and the right to store and retrieve one copy of the work, you may not decompile, disassemble, reverse engineer, reproduce, modify, create derivative works based upon, transmit, distribute, disseminate, sell, publish or sublicense the work or any part of it without McGraw-Hill’s prior consent. You may use the work for your own noncommercial and personal use; any other use of the work is strictly prohibited. Your right to use the work may be terminated if you fail to comply with these terms.
THE WORK IS PROVIDED “AS IS.” McGRAW-HILL AND ITS LICENSORS MAKE NO GUARANTEES OR WARRANTIES AS TO THE ACCURACY, ADEQUACY OR COMPLETENESS OF OR RESULTS TO BE OBTAINED FROM USING THE WORK, INCLUDING ANY IN- FORMATION THAT CAN BE ACCESSED THROUGH THE WORK VIA HYPERLINK OR OTHERWISE, AND EXPRESSLY DISCLAIM ANY WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY OR FIT- NESS FOR A PARTICULAR PURPOSE. McGraw-Hill and its licensors do not warrant or guarantee that the functions contained in the work will meet your requirements or that its operation will be uninterrupted or error free. Neither McGraw-Hill nor its licensors shall be liable to you or anyone else for any inaccuracy, error or omission, regardless of cause, in the work or for any damages resulting therefrom. McGraw-Hill has no responsibility for the content of any information accessed through the work. Under no circumstances shall McGraw-Hill and/or its licensors be liable for any indirect, incidental, special, punitive, consequential or similar damages that result from the use of or inability to use the work, even if any of them has been advised of the possibility of such damages. This limitation of liability shall apply to any claim or cause whatsoever whether such claim or cause arises in contract, tort or otherwise.
To my late father, Hugh Monk, from whom I inherited a love for electronics. He would have had so much fun with all this.
Contents
Acknowledgments.................................................. ix
- 1 Quickstart Introduction xi - Powering Up - Installing the Software. - Configuring Your Arduino Environment - Downloading the Project Software - Project 1 Flashing LED - Breadboard. - Summary Introduction
ARDUINO INTERFACE BOARDS provide the Evil Genius with a low-cost, easy-to-use technology to create their evil projects. A whole new breed of projects can now be built that can be controlled from a computer. Before long, the computer- controlled, servo-driven laser will be complete and the world will be at the mercy of the Evil Genius!
This book will show the Evil Genius how to attach an Arduino board to their computer, to program it, and to connect all manner of electronics to it to create projects, including the computer-controlled, servo-driven laser mentioned earlier, a USB-controlled fan, a light harp, a USB temperature logger, a sound oscilloscope, and many more.
Full schematic and construction details are provided for every project, and most can be built without the need for soldering or special tools. However, the more advanced Evil Genius may wish to transfer the projects from a plug-in breadboard to something more permanent, and instructions for this are also provided.
So, What Is Arduino?
Well, Arduino is a small microcontroller board with a USB plug to connect to your computer and a number of connection sockets that can be wired up to external electronics, such as motors, relays, light sensors, laser diodes, loudspeakers, microphones, etc. They can either be powered through the USB connection from the computer or from a 9V battery. They can be controlled from the computer or programmed by the computer and then disconnected and allowed to work independently.
At this point, the Evil Genius might be wondering which top secret government organization they need to break into in order to acquire one. Well, disappointingly, no evil deeds at all are required to obtain one of these devices. The Evil Genius needs to go no further than their favorite online auction site or search engine. Since the Arduino is an open-source hardware design, anyone is free to take the designs and create their own clones of the Arduino and sell them, so the market for the boards is competitive. An official Arduino costs about $30, and a clone often less than $20. The name “Arduino” is reserved by the original makers. However, clone Arduino designs often have the letters “duino” on the end of their name, for example, Freeduino or DFRduino. The software for programming your Arduino is easy to use and also freely available for Windows, Mac, and LINUX computers at no cost.
Arduino
Although Arduino is an open-source design for a microcontroller interface board, it is actually rather more than that, as it encompasses the software development tools that you need to program an Arduino board, as well as the board itself. There is a large community of construction, programming, electronics, and even art enthusiasts willing to share their expertise and experience on the Internet. To begin using Arduino, first go to the Arduino site (www.arduino.cc) and download the software for Mac, PC, or LINUX. You can then either buy an official Arduino by clicking the Buy An
xi
Introduction xiii
each other. So a design might have three layers: an Arduino board on the bottom, a GPS shield on it, and then an LCD display shield on top of that.
The Projects
The projects in this book are quite diverse. We begin with some simple examples using standard LEDs and also the ultra high-brightness Luxeon LEDs.
In Chapter 5, we look at various sensor projects for logging temperature and measuring light and pressure. The USB connection to the Arduino makes it possible to take the sensor readings in these projects and pass them back to the computer, where they can be imported into a spreadsheet and charts drawn.
We then look at projects using various types of display technology, including an alphanumeric LCD message board (again using USB to get messages from your computer), as well as seven- segment and multicolor LEDs.
Chapter 7 contains four projects that use sound as well as a simple oscilloscope. We have a simple project to play tunes from a loudspeaker, and build up to a light harp that changes the pitch and volume of the sound by waving your hand over light sensors. This produces an effect rather like the famous Theremin synthesizer. The final project in this chapter uses sound input from a microphone. It is a VU meter that displays the intensity of the sound on an LED display.
The final chapters contain a mixture of projects. Among others, there is, as we have already mentioned, an unfathomable binary clock using an Arduino Lilypad board that indicates the time in an obscure binary manner only readable by an Evil Genius, a lie detector, a motor-controlled swirling hypnotizer disk, and, of course, the computer- controlled-servo-guided laser.
Most of the projects in this book can be constructed without the need for soldering; instead we use a breadboard. A breadboard is a plastic block with holes in it with sprung metal connections behind. Electronic components are pushed through the holes at the front. These are not expensive, and a suitable breadboard is also listed in the appendix. However, if you wish to make your designs more permanent, the book shows you how to do that, too, using the prototyping board. Sources for all the components are listed in the appendix, along with some useful suppliers. The only things you will need in addition to these components are an Arduino board, a computer, some wire, and a piece of breadboard. The software for all the projects is available for download from www.arduinoevilgenius.com.
Without Further Ado
The Evil Genius is not noted for their patience, so in the next chapter we will show you how to get started with Arduino as quickly as possible. This chapter contains all the instructions for installing the software and programming your Arduino board, including downloading the software for the projects, so you will need to read it before you embark on your projects. In Chapter 2 we take a look at some of the essential theory that will help you build the projects described in this book, and go on to design projects of your own. Most of the theory is contained in this chapter, so if you are the kind of Evil Genius who prefers to just make the projects and find out how they work afterwards, you may prefer, after reading Chapter 1, to just to pick a project and start building. Then if you get stuck, you can use the index or read some of the early chapters.
Install the Arduino development environment, which is the program that you run on your computer that enables you to write sketches and download them to the Arduino board.
The Arduino website (www.arduino.cc) contains the latest version of the software.
Follow the download link on the Arduino home page (www.arduino.cc) and select the download for Windows. This will start the download of the Zip archive containing the Arduino software, as shown in Figure 1-2. You may well be downloading a more recent version of the software than the version 17 shown. This should not matter, but if you experience any problems, refer back to the instructions on the Arduino home page.
The Arduino software does not distinguish between different versions of Windows. The download should work for all versions, from Windows XP onwards. The following instructions are for Windows XP.
Select the Save option from the dialog, and save the Zip file onto your desktop. The folder contained in the Zip file will become your main Arduino directory, so now unzip it into C:\Program Files\Arduino. You can do this in Windows XP by right- clicking the Zip file to show the menu in Figure 1-3 and selecting the Extract All option. This will open the Extraction Wizard, shown in Figure 1-4.
2 30 Arduino Projects for the Evil Genius
Figure 1-1 A powered-up Arduino board with LED lit.
Downloading the Arduino software for Windows.
Figure 1-
Click Next and then modify the folder to extract files to C:\Program Files\Arduino as shown in Figure 1-5. Then click Next again.
This will create a new directory for this version of Arduino (in this case, 17) in the folder C:\Program Files\Arduino. This allows you to have multiple versions of Arduino installed at the same time, each in its own folder. Updates of Arduino are fairly infrequent and historically have always kept compatibility with earlier versions of the software. So unless there is a new feature of the software that you want to use, or you have been having problems, it is by no means essential to keep up with the latest version.
Now that we have got the Arduino folder in the right place, we need to install the USB drivers. We let Windows do this for us by plugging in the Arduino board to trigger the Windows Found New Hardware Wizard shown in Figure 1-6.
Select the option No, Not This Time, and then click Next. On the next screen (Figure 1-7), click the option to install from a specified location, enter or browse to the location C:\Program Files\Arduino\arduino- 0017\drivers\FTDI USB Drivers, and then click Next. Note that you will have to change 0017 in the path noted if you download a different version. The installation will then complete and you are ready to start up the Arduino software itself. To do this, go to My Computer, navigate to C:\Program
Chapter 1 ■ Quickstart 3
The Extract All menu option in Windows.
Figure 1-
Extracting the Arduino file in Windows.
Figure 1-
Figure 1-5 Setting the directory for extraction.