Arduino code and Video for HC-SR501 Motion Sensor Robojax.com

This is the Arduino code for HC-SR501 Motion Sensor

This video shows you how to use HC-SR501 Sensor for arduino. http://robojax.com/learn/arduino/
  1. HC-SR501 Motion Sensor Manual
  2. LHI778 Motion Sensor Manual

 /*
 * This is the Arduino code for  HC-SR501 Motions Sensor
 * to tetect motion of human or objects using arduino for robotoic car and other applications
 * Watch the video https://youtu.be/mZCJNOf69JI
 *  * 
 * Written by Ahmad Nejrabi for Robojax Video
 * Date: Dec 27, 2017, in Ajax, Ontario, Canada
 * Permission granted to share this code given that this
 * note is kept with the code.
 * Disclaimer: this code is "AS IS" and for educational purpose only.
 * 
 */

/void setup() {
  Serial.begin(9600);// setup Serial Monitor to display information
  pinMode(2, INPUT);// Input from sensor
  pinMode(8, OUTPUT);// OUTPUT to alarm or LED
}

void loop() {
  int motion =digitalRead(2);
  if(motion){
    Serial.println("Motion detected");
    digitalWrite(8,HIGH);
  }else{
     Serial.println("===nothing moves");
     digitalWrite(8,LOW);
  }
  delay(500);

}