Arduino for Secret Agents 1st Edition Schwartz 2024 scribd download
Arduino for Secret Agents 1st Edition Schwartz 2024 scribd download
com
https://ebookname.com/product/arduino-for-secret-agents-1st-
edition-schwartz/
OR CLICK BUTTON
DOWNLOAD EBOOK
https://ebookname.com/product/arduino-android-blueprints-1st-edition-
schwartz/
ebookname.com
https://ebookname.com/product/programming-arduino-with-labview-1st-
edition-marco-schwartz/
ebookname.com
https://ebookname.com/product/raspberry-pi-for-secret-agents-2nd-
edition-stefan-sjogelid/
ebookname.com
https://ebookname.com/product/the-new-bruckner-compositional-
development-and-the-dynamics-of-revision-1st-edition-dermot-gault/
ebookname.com
Architextiles Architectural Design 11 12 2006 Vol 76 N 6
1st Edition Mark Garcia
https://ebookname.com/product/architextiles-architectural-
design-11-12-2006-vol-76-n-6-1st-edition-mark-garcia/
ebookname.com
https://ebookname.com/product/white-lies-christopher-m-driscoll/
ebookname.com
https://ebookname.com/product/first-pure-then-peaceable-frederick-
douglass-reads-james-1st-edition-margaret-aymer/
ebookname.com
https://ebookname.com/product/illinois-politics-a-citizen-s-guide-1st-
edition-james-d-nowlan/
ebookname.com
Working with Adolescents A Guide for Practitioners 1st
Edition Julie Anne Laser Msw Lcsw Phd
https://ebookname.com/product/working-with-adolescents-a-guide-for-
practitioners-1st-edition-julie-anne-laser-msw-lcsw-phd/
ebookname.com
[1]
Arduino for Secret Agents
Marco Schwartz
BIRMINGHAM - MUMBAI
Arduino for Secret Agents
All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy
of the information presented. However, the information contained in this book is
sold without warranty, either express or implied. Neither the author, nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.
ISBN 978-1-78398-608-8
www.packtpub.com
Credits
Reviewer Proofreader
Roberto Gallea Safis Editing
Technical Editor
Bharat Patil
Copy Editor
Vibha Shukla
About the Author
He has more than five years of experience working in the domain of electrical
engineering. Marco's interests gravitate around electronics, home automation,
the Arduino and Raspberry Pi platforms, open source hardware projects,
and 3D printing.
He has several websites about Arduino, including the Open Home Automation website
that is dedicated to building home automation systems using open source hardware.
Marco has written another book on home automation and Arduino, called Home
Automation With Arduino: Automate Your Home Using Open-source Hardware. He has
also written a book on how to build Internet of Things projects with Arduino, called
Internet of Things with the Arduino Yun, Packt Publishing.
About the Reviewer
Roberto Gallea, PhD, is a computer science researcher since 2007. He was working
at the University of Palermo, Italy. He is committed to investigating fields such as
medical imaging, multimedia, and computer vision. In 2012, he started enhancing
his academic and personal projects with the use of analog and digital electronics,
with particular involvement in the open source hardware and software platform,
Arduino. Besides academic interests, he also conducts personal projects that are
aimed at producing handcrafted items embedding invisible electronics, such as
musical instruments, furniture, and LED devices. He has also been collaborating
with contemporary dance companies for digital scenic and costume design.
www.PacktPub.com
Did you know that Packt offers eBook versions of every book published, with PDF
and ePub files available? You can upgrade to the eBook version at www.PacktPub.com
and as a print book customer, you are entitled to a discount on the eBook copy. Get in
touch with us at service@packtpub.com for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign
up for a range of free newsletters and receive exclusive discounts and offers on Packt
books and eBooks.
TM
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital
book library. Here, you can search, access, and read Packt's entire library of books.
Why subscribe?
• Fully searchable across every book published by Packt
• Copy and paste, print, and bookmark content
• On demand and accessible via a web browser
[i]
Table of Contents
[ ii ]
Preface
The Arduino platform makes it really easy to build electronics projects in various
domains, such as home automation, Internet of Things, wearable technology, and
even healthcare. It's also the ideal platform to build amazing projects for secret
agents, which is what we are going to do in this book.
Using the power and simplicity of the Arduino platform, we are going to see how
to build several projects that can be easily used by any aspiring secret agent. From
audio recorders to GPS trackers, you will be able to make your own secret agent
toolkit using the Arduino platform after reading this book.
Chapter 2, Creating a Spy Microphone, is about making a secret recording system that
can record the conversations and noises in a room.
Chapter 3, Building an EMF Bug Detector, is about creating a very useful device for
any secret agent: a detector to check whether there are other secret agent devices
in a room.
Chapter 4, Access Control with a Fingerprint Sensor, is about creating an access control
system using your own fingerprint.
Chapter 5, Opening a Lock with an SMS, is about building a project where the secret
agent can open a lock just by sending a text message to the Arduino device.
Chapter 6, Building a Cloud Spy Camera, is about making a spy camera that can be
accessed from anywhere in the world and can record pictures in Dropbox when
motion is detected.
[ iii ]
Preface
Chapter 7, Monitoring Secret Data from Anywhere, is about learning how to secretly
record any kind of data and how to log in this data on the Cloud.
Chapter 8, Creating a GPS Tracker with Arduino, is about creating one of the most
useful devices for a secret agent: a GPS tracker that indicates its position on a
map in real time.
Chapter 9, Building an Arduino Spy Robot, is about making a small surveillance robot
that can spy on your behalf.
We will be using a wide range of Arduino boards, shields, and hardware components.
You will find all the details about these requirements in the relevant chapters.
Conventions
In this book, you will find a number of text styles that distinguish between different
kinds of information. Here are some examples of these styles and an explanation of
their meaning.
Code words in text, database table names, folder names, filenames, file extensions,
pathnames, dummy URLs, user input, and Twitter handles are shown as follows:
"Also, if the alarm_mode is going back to false, we need to deactivate the alarm
immediately."
[ iv ]
Preface
New terms and important words are shown in bold. Words that you see on the
screen, for example, in menus or dialog boxes, appear in the text like this: "Now,
inside the parameters of the app, there are two things you need: the App key, and
the App secret."
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about
this book—what you liked or disliked. Reader feedback is important for us as it
helps us develop titles that you will really get the most out of.
If there is a topic that you have expertise in and you are interested in either writing
or contributing to a book, see our author guide at www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to
help you to get the most from your purchase.
[v]
Preface
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes
do happen. If you find a mistake in one of our books—maybe a mistake in the text or
the code—we would be grateful if you could report this to us. By doing so, you can
save other readers from frustration and help us improve subsequent versions of this
book. If you find any errata, please report them by visiting http://www.packtpub.
com/submit-errata, selecting your book, clicking on the Errata Submission Form
link, and entering the details of your errata. Once your errata are verified, your
submission will be accepted and the errata will be uploaded to our website or added
to any list of existing errata under the Errata section of that title.
Piracy
Piracy of copyrighted material on the Internet is an ongoing problem across all
media. At Packt, we take the protection of our copyright and licenses very seriously.
If you come across any illegal copies of our works in any form on the Internet, please
provide us with the location address or website name immediately so that we can
pursue a remedy.
We appreciate your help in protecting our authors and our ability to bring you
valuable content.
Questions
If you have a problem with any aspect of this book, you can contact us at
questions@packtpub.com, and we will do our best to address the problem.
[ vi ]
A Simple Alarm System
with Arduino
I want to start this book with a simple project that any secret agent will want to
have, a simple alarm system that will be activated whenever motion is detected by
a sensor. This simple system is not only fun to make but will also help us to go over
the basics of Arduino programming and electronics, which are the skills that we will
use in this whole book.
It will basically be a simple alarm (a buzzer that makes sound, plus a red LED)
combined with a motion detector. The user will also be able to stop the alarm by
pressing a button.
• First, we are going to see what the requirements for this project are, in terms
of hardware and software
• Then, we will see how to assemble the hardware parts for this project
• After that, we will configure our system using the Arduino IDE
[1]
A Simple Alarm System with Arduino
The first component that will be central to the project is the Arduino Uno board:
In several chapters of this book, this will be the 'brain' of the projects that we will
make. In all the projects, I will be using the official Arduino Uno R3 board. However,
you can use an equivalent board from another brand or another Arduino board, such
as an Arduino Mega board.
[2]
Chapter 1
This is a very simple component that is used to make simple sounds with Arduino.
You couldn't play an MP3 with it but it's just fine for an alarm system. You can, of
course, use any buzzer that is available; the goal is to just make a sound.
Here, I used a very simple PIR motion detector. This sensor will measure the infrared
(IR) light that is emitted by moving objects in its field of view, for example, people
moving around. It is really easy and quite cheap to interface with Arduino. You can
use any brand that you want for this sensor; it just needs a voltage level of 5V in
order to be compatible with the Arduino Uno board.
Finally, here is the list of all the components that we will use in this project:
[3]
A Simple Alarm System with Arduino
On the software side, the only thing that we will need in the first chapter is the
latest version of the Arduino IDE that you can download from the following URL:
https://www.arduino.cc/en/main/software.
Note that we are going to use the Arduino IDE in all the projects of this book, so
make sure to install the latest version.
Hardware configuration
We are now going to assemble the hardware for this project. As this is the first
project of this book, it will be quite simple. However, there are quite a lot of
components, so be sure to follow all the steps.
Let's start by putting all the components on the board. Place the buzzer, button, and
LED on the board first, according to the schematics. Then, place the 330 Ohm resistor
in series with the LED anode (the longest pin) and connect the 1k Ohm resistor to
one pin of the push button.
[4]
Chapter 1
Let's start with the power supply. Connect the 5V pin of the Arduino board to one
red power rail of the breadboard, and the GND pin of the Arduino board to one blue
power rail of the breadboard.
Then, we are going to connect the buzzer. Connect one pin of the buzzer to pin number
5 of the Arduino board and the other pin to the blue power rail of the breadboard.
After that, let's connect the LED. Connect the free pin of the resistor to pin number 6
of the Arduino board and the free pin of the LED (the cathode) to the ground via the
blue power rail.
Let's also connect the push button to our Arduino board. Refer to the schematic to
be sure about the connections since it is a bit more complex. Basically, you need
to connect the free pin of the resistor to the ground and connect the pin that is
connected to the button to the 5V pin via the red power rail. Finally, connect the
other side of the button to pin 12 of the Arduino board.
[5]
A Simple Alarm System with Arduino
Finally, let's connect the PIR motion sensor to the Arduino board. Connect the VCC
pin of the motion sensor to the red power rail and the GND pin to the blue power
rail. Finally, connect the SIG pin (or OUT pin) to Arduino pin number 7.
If your project looks similar to this picture, congratulations, you just assembled your
first secret agent project! You can now go on to the next section.
[6]
Chapter 1
// Pins
const int alarm_pin = 5;
const int led_pin = 6;
const int motion_pin = 7;
const int button_pin = 12;
// Alarm
boolean alarm_mode = false;
void setup()
{
// Set pins to output
pinMode(led_pin,OUTPUT);
pinMode(alarm_pin,OUTPUT);
void loop()
{
// Motion detected ?
if (digitalRead(motion_pin)) {
alarm_mode = true;
}
// If alarm mode is on, flash the LED and make the alarm ring
if (alarm_mode){
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > interval) {
previousMillis = currentMillis;
if (ledState == LOW)
[7]
A Simple Alarm System with Arduino
ledState = HIGH;
else
ledState = LOW;
// Switch the LED
digitalWrite(led_pin, ledState);
}
tone(alarm_pin,1000);
}
// If alarm is off
if (alarm_mode == false) {
We are now going to see, in more detail, the different parts of the code. It starts by
declaring which pins are connected to different elements of the project, such as the
alarm buzzer:
const int alarm_pin = 5;
const int led_pin = 6;
const int motion_pin = 7;
const int button_pin = 12;
[8]
Chapter 1
After that, in the setup() function of the sketch, we declare these pins as either
inputs or outputs, as follows:
// Set pins to output
pinMode(led_pin,OUTPUT);
pinMode(alarm_pin,OUTPUT);
Then, in the loop() function of the sketch, we check whether the alarm was
switched on by checking the state of the motion sensor:
if (digitalRead(motion_pin)) {
alarm_mode = true;
}
Note that if we detect some motion, we immediately set the alarm_mode variable to
true. We will see how the code makes use of this variable right now.
Now, if the alarm_mode variable is true, we have to enable the alarm, make the buzzer
emit a sound, and also flash the LED. This is done by the following code snippet:
if (alarm_mode){
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > interval) {
previousMillis = currentMillis;
if (ledState == LOW)
ledState = HIGH;
else
ledState = LOW;
// Switch the LED
digitalWrite(led_pin, ledState);
}
tone(alarm_pin,1000);
}
[9]
A Simple Alarm System with Arduino
Finally, we continuously read the state of the push button. If the button is pressed,
we will immediately set the alarm off:
int button_state = digitalRead(button_pin);
if (button_state) {alarm_mode = false;}
Usually, we should take care of the bounce effect of the button in order to make
sure that we don't have erratic readings when the button is pressed. However, here
we only care about the button actually being pressed so we do not need to add an
additional debouncing code for the button.
Note that you can find all the code for this project inside the GitHub repository of
the book:
https://github.com/marcoschwartz/arduino-secret-agents
Now that we have written down the code for the project, it's time to get to the most
exciting part of the chapter: testing the alarm system!
In the IDE, choose the right board type (for example, Arduino Uno) and also the
correct serial port.
You can now upload the code to the board. Once it is done, simply pass your hand
in front of the PIR motion sensor; the alarm should go off immediately. Then, simply
press the push button to stop it.
[ 10 ]
Chapter 1
To illustrate the behavior of the alarm, I simply used a battery pack to make it work
when it is not connected to my computer. The following is the result when the alarm
goes off:
If this works as expected, congratulations, you just built your first secret agent
project: a simple alarm system based on Arduino!
If it doesn't work well at this point, there are several things you can check. First, go
through the hardware configuration part again to make sure that your project is
correctly configured.
Also, you can verify that when you pass your hand in front of the PIR sensor, it goes
red. If this is not the case, most probably your PIR motion sensor has a problem and
must be replaced.
[ 11 ]
A Simple Alarm System with Arduino
Summary
In this first chapter, we built a simple alarm based on Arduino with only a
few components.
There are several ways to go further and improve this project. You can add more
functions to the project just by adding more lines to the code. For example, you
can add a timer so that the alarm only goes off after a given amount of time, or
you can build a mode where a push of the button actually activates or deactivates
the alarm mode.
In the next chapter, we are going to build another project that is very useful for secret
agents: an audio recording device based on Arduino!
[ 12 ]
Random documents with unrelated
content Scribd suggests to you:
and 1874. We feel at liberty to call attention to some manuscript
alterations made by the author in our copy. For Coturniculus
passerinus read Zonotrichia albicollis; for Myiarchus crinitus, read
Tyrannus verticalis; for Archibuteo lagopus, read A. ferrugineus,
the range of which is thus carried beyond any point hitherto given;
for Tringa canutus read T. bairdi; for Podilymbus podiceps, read
Podiceps californicus. We could wish the report were better printed;
but poor presswork is the usual fate of public documents, English or
American.—E. C.
Errata.
In Vol. VII, page 26, line 6, for “An indistinct, dusky” read “A
black.” Same page, foot note, for “οὐκέω” read “οἰκέω.”
Bull. Nutt. Ornith. Club., Vol. VII., No.
3. Plate 7.
EXPLANATION OF PLATE I.
Fig. 1. Diagramatic representation of the effect of a film on light.
Fig. 2. Transverse section of a barb of Chlorophanes atrocristatus; Hartnack 3–
9 im. the light part yellow, the dark part dark brown.
Fig. 3. Transverse section of a barb of Cyanocitta cristata. Hart. 3–9 im.
Fig. 4. Same of Cyanospiza cyanea ♂.
Fig. 5. Two sections of a barbule of a Peacock.
Fig. 6. Section of barb of Sialia sialis much magnified.