Back to Step by Step Course by Robojax

Lesson 16, Robojax Arduino Step by Step Course: Motion Sensor

If you don't like to see ads while video is being played you can purchase YouTube premium Here

This is the Arduino code this code when motion is detected, will send signal to pin 8 which can be a buzzer or relay


 /*
 * Robojax Arduino Step By Step Course
 * Lesson 16 HC-SR501 Motion Sensor
 * Arduino code for HC-SR501 PIR Motion Sensor
 this code when motion is detected, will send signal to pin 8 which can be a buzzer or relay

  Please watch video instruction here https://youtu.be/piuUfGVafC0
 This code is available at http://robojax.com/course1/?vid=lecture11
 
with over 100 lectures Free On  YouTube Watch it here http://robojax.com/L/?id=338
Get the code for the course: http://robojax.com/L/?id=339 

 * on January 16, 2019 at 20:23 in Ajax, Ontario, Canada

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */
int pirPin = 2;// input pin from PIR sensor
int alarmPin = 8;// Alarm pin to turn alarm ON
 
void setup() {
	
	//Robojax Arduino Step By Step Course http://robojax.com/L/?id=338
  Serial.begin(9600);// setup Serial Monitor to display information
  pinMode(pirPin, INPUT);// Input from sensor
  pinMode(alarmPin, OUTPUT);// OUTPUT to alarm or LED
}

void loop() {
	//Robojax Arduino Step By Step Course http://robojax.com/L/?id=338	
  int motion =digitalRead(pirPin);// read input pin signal
  if(motion == HIGH){
    Serial.println("Motion detected");
    digitalWrite(alarmPin,HIGH);
  }else{
     Serial.println("===nothing moves");
     digitalWrite(alarmPin,LOW);
  }
  delay(500);

}


   

The least I expect from you is to thumb up the video and subscribe to my channel. I appriciate that. .I have spent months making these lectures and writing code. You don't lose anything by subscribging to my channel. Your subscription is stamp of approval to my videos and more people can find them and in it turn it helps me. Thank you

If you found this tutorial helpful, please support me so I can continue creating content like this. support me via PayPal

**** AFFILIATE PROGRAM **** We are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites.

Right Side
footer