Reader small image

You're reading from  Arduino By Example

Product typeBook
Published inSep 2015
Reading LevelIntermediate
Publisher
ISBN-139781785289088
Edition1st Edition
Languages
Tools
Right arrow
Authors (2):
 Adith Jagadish Boloor
Adith Jagadish Boloor
author image
Adith Jagadish Boloor

Adith Jagadish Boloor was born in Mangalore, India. He grew up tinkering with toys and gadgets that kindled his interest in how things work. His admiration for science and technology, specifically in the fields of robotics, 3D printing, and smart systems, grew into a passion that he is working towards, nurturing it into a career. He completed his higher studies at Purdue University, USA and Shanghai Jiao Tong University, China and is working towards obtaining a masters degree in robotics. Adith has experience working on robots ranging from simple obstacle—avoiding robots built at home to complex humanoid robots such as the Darwin-OP in Purdue University's research lab. He has coauthored a research paper and has two patents on his name. He enjoys traveling and grabs every opportunity he can to explore the different parts of the world. He is also an international chess player.
Read more about Adith Jagadish Boloor

Adith Jagdish Boloor
Adith Jagdish Boloor
author image
Adith Jagdish Boloor

<p>Adith Jagadish Boloor was born in Mangalore, India. He grew up tinkering with toys and gadgets that kindled his interest in how things work. His admiration for science and technology, specifically in the fields of robotics, 3D printing, and smart systems, grew into a passion that he is working towards, nurturing it into a career. He completed his higher studies at Purdue University, USA and Shanghai Jiao Tong University, China and is working towards obtaining a masters degree in robotics.</p> <p>Adith has experience working on robots ranging from simple obstacle—avoiding robots built at home to complex humanoid robots such as the Darwin-OP in Purdue University's research lab. He has coauthored a research paper and has two patents on his name.</p> <p>He enjoys traveling and grabs every opportunity he can to explore the different parts of the world. He is also an international chess player.</p>
Read more about Adith Jagdish Boloor

View More author details
Right arrow

A mini PIR-Arduino alarm


Let's get started. We are going to create a setup in which an LED flashes when motion is detected by the PIR sensor. This is what the setup should look like when connecting the Arduino to the PIR Sensor:

Basically, the connections are as follows:

  • GND → GND

  • VCC → 5V

  • OUT → D02 (digital pin 2)

Note

Digital pins are denoted using D and analog pins are denoted by A. So digital pin 13 is D13 and analog pin 2 is A02.

Open Arduino and load the sketch called PIR_LED.ino, or copy this:

int ledPin = 13; // use the onboard LED
int pirPin = 2; // 'out' of PIR connected to digital pin 2
int pirState = LOW; // start the state of the PIR to be low (no motion)
int pirValue = 0; // variable to store change in PIR value

void setup() {
  pinMode(ledPin, OUTPUT); // declare the LED as output
  pinMode(pirPin, INPUT);  // declare the PIR as input
  Serial.begin(9600); // begin the Serial port at baud 9600
}

void loop() {
  pirValue = digitalRead(pirPin); // read PIR value
  if ((pirValue =...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Arduino By Example
Published in: Sep 2015Publisher: ISBN-13: 9781785289088

Authors (2)

author image
Adith Jagadish Boloor

Adith Jagadish Boloor was born in Mangalore, India. He grew up tinkering with toys and gadgets that kindled his interest in how things work. His admiration for science and technology, specifically in the fields of robotics, 3D printing, and smart systems, grew into a passion that he is working towards, nurturing it into a career. He completed his higher studies at Purdue University, USA and Shanghai Jiao Tong University, China and is working towards obtaining a masters degree in robotics. Adith has experience working on robots ranging from simple obstacle—avoiding robots built at home to complex humanoid robots such as the Darwin-OP in Purdue University's research lab. He has coauthored a research paper and has two patents on his name. He enjoys traveling and grabs every opportunity he can to explore the different parts of the world. He is also an international chess player.
Read more about Adith Jagadish Boloor

author image
Adith Jagdish Boloor

<p>Adith Jagadish Boloor was born in Mangalore, India. He grew up tinkering with toys and gadgets that kindled his interest in how things work. His admiration for science and technology, specifically in the fields of robotics, 3D printing, and smart systems, grew into a passion that he is working towards, nurturing it into a career. He completed his higher studies at Purdue University, USA and Shanghai Jiao Tong University, China and is working towards obtaining a masters degree in robotics.</p> <p>Adith has experience working on robots ranging from simple obstacle—avoiding robots built at home to complex humanoid robots such as the Darwin-OP in Purdue University's research lab. He has coauthored a research paper and has two patents on his name.</p> <p>He enjoys traveling and grabs every opportunity he can to explore the different parts of the world. He is also an international chess player.</p>
Read more about Adith Jagdish Boloor