Contents
Guide
Arduino and Raspberry Pi Sensor Projectsfor the Evil Genius
Library of Congress Control Number: 201794884
McGraw-Hill Education books 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 visit the Contact Us page at www.mhprofessional.com.
Arduino and Raspberry Pi Sensor Projects for the Evil Genius
Copyright 2018 by McGraw-Hill Education. All rights reserved. Printed in the United States of America. 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.
McGraw-Hill Education, the McGraw-Hill Education logo, Evil Genius and TAB, and related trade dress are trademarks or registered trademarks of McGraw-Hill Education and/or its affiliates in the United States and other countries and may not be used without written permission. All other trademarks are the property of their respective owners. McGraw-Hill Education is not associated with any product or vendor mentioned in this book.
1 2 3 4 5 6 7 8 9 DSS 22 21 20 19 18 17
ISBN 978-1-260-01089-3
MHID 1-260-01089-9
e-ISBN 978-1-260-01090-9
e-MHID 1-260-01090-2
This book is printed on acid-free paper.
Sponsoring Editor
Michael McCabe
Editorial Supervisor
Donna M. Martone
Production Supervisor
Lynn M. Messina
Acquisitions Coordinator
Lauren Rogers
Project Manager
Patricia Wallenburg, TypeWriting
Copy Editor
James Madru
Proofreader
Claire Splan
Indexer
Claire Splan
Art Director, Cover
Jeff Weeks
Composition
TypeWriting
Information contained in this work has been obtained by McGraw-Hill Education from sources believed to be reliable. However, neither McGraw-Hill Education nor its authors guarantee the accuracy or completeness of any information published herein, and neither McGraw-Hill Education nor its authors shall be responsible for any errors, omissions, or damages arising out of use of this information.
About the Author
Robert Chin has a Bachelor of Science degree in computer engineering and is experienced in developing projects on the TI CC3200 SimpleLink, Android, Arduino, Raspberry Pi, and PC Windows platforms using C/C++, Java, Python, Unreal Script, DirectX, OpenGL, and OpenGL ES 2.0. He is the author of Home Security System DIY PRO Using Android and TI CC3200 SimpleLink, Home Security Systems DIY Using Android and Arduino, and Beginning Arduino ov7670 Camera Development. He is also the author of Beginning Android 3d Game Development and Beginning IOS 3d Unreal Games Development, both published by Apress, and was the technical reviewer for UDK Game Development, published by Course Technology CENGAGE Learning. Beginning Android 3d Game Development was licensed to Tsinghua University through Tsinghua University Press.
Contents
CHAPTER 1
Introducing the Arduino and Raspberry Pi
THIS CHAPTER WILL INTRODUCE YOU to the Arduino and the Raspberry Pi. First, I give a brief explanation of what the Arduino is. Then I specifically address the Arduino Uno, discussing its general features, including its capabilities and key functional components. This is followed by a discussion of the Arduino Integrated Development Environment (IDE) software, which is needed to develop programs for the Arduino. Each key function of the Arduino IDE is reviewed, followed by a hands-on example giving detailed step-by-step instructions on how to set up the Arduino for development and how to run and modify an example program using the Arduino IDE. Next comes the Raspberry Pi. I discuss what the Raspberry Pi is and the specifications for the Raspberry Pi 3. This section tells you how to set up the Raspberry Pi before using it for the first time. Raspberry Pi hardware features are addressed, including the general purpose input-output (GPiO) pin specifications. The final section includes a hands-on example of how to control a light-emitting diode (LED) using the Raspberry Pi.
What Is an Arduino?
The Arduino is an open-source microcontroller that uses the C and C++ languages to control digital and analog outputs to devices and electronic components and to read in digital and analog inputs from other devices and electronic components for processing. For example, an Arduino can read a signal from a sensor in a home security system that detects the heat that a human being emits. The sensor sends a signal to the Arduino indicating that a person is in the home. After receiving this information, the Arduino can send commands to a camera such as the ArduCAM Mini digital camera to start taking pictures of the intruder. There are many different Arduino models out there. However, to create the examples in this book, you will need an Arduino model with enough pins to connect the components you desire, such as a camera, Bluetooth adapter, and/or motion sensor. shows the official Arduino logo.
Figure 1-1 | Official Arduino logo. |
Note: The official website of the Arduino is www.arduino.cc.
Arduino Uno
There are a great many Arduino products out there, ranging from models that are small and can actually be worn by the user to models with many digital and analog input-output pins. For the projects in this book, I recommend the Arduino Uno, which is an open-source microcontroller that has enough digital ports to accommodate a camera, a Secure Digital (SD) card reader/writer with enough digital and analog ports for other devices, sensors, lights, and any other gadgets that you may require for your own custom projects. The official Arduino Uno board is made by a company called Arduino SRL, formerly Smart Projects, formed by one of the founders of the Arduino (). The newer official Arduino Uno boards are slightly different in that they are more blue-green instead of blue in color and contain the Genuino logo under the main Arduino logo. The Genuino trademark is used outside the United States as a result of the split between Arduino founders.
Figure 1-2 | The official Arduino Uno. |
There are also unofficial Arduino Uno boards made by other companies. A good way to tell whether a board is official or unofficial is by the color of a component that is located near the Arduinos USB port. This component on an official Arduino board is a metallic gold color. The component on an unofficial board is green. The writing on the components also differs ().
Figure 1-3 | Metallic gold colored component on an official Arduino Uno board. |
A number of other companies also manufacture Arduino Uno boards. Because the Arduino is an open-source item, other companies can legally manufacture the board, and the boards vary in quality and price. Generally, an unofficial Arduino Uno costs around $10, and an official Arduino Uno costs around $20. The distinguishing parts of an official Arduino board are the golden component and the high-quality Arduino and Genuino logos printed on the board ().