ChandanShamala Library

Developing Communities                                                                          Be Good Do Good

Chandler 85248
chandan@chandanshamalalibrary.org

  • Home
  • About Us
  • Volunteering Opportunities
  • How You Can Help
  • AZ FLL Pictures
  • USA ChaptersClick to open the USA Chapters menu
    • BAY AREA - San Jose Chapter
    • Raspberry Pi classes
  • IndiaClick to open the India menu
    • Certificate of Registration
    • Memorandum of Association
    • India Home
    • Medical Camp
    • Blood Donors Group at Goalpara
  • STEM Videos from the Web
  • Mobile STEM/IOT/Robotics LaboratoryClick to open the Mobile STEM/IOT/Robotics Laboratory menu
    • DIY: Solar Energy System
  • Make your Own Phone
  • Makers - Lets Start!
  • Intel Edison ClassesClick to open the Intel Edison Classes menu
    • Intel Edison 101
    • Intel Edison 201
    • Intel Edison 301
  • Intel Edison ProjectsClick to open the Intel Edison Projects menu
    • Intel Edison Setup
    • BlinkWithoutDelay
    • Hello World with Grove LCD
    • Grove Light Sensor
    • Grove Moisture Sensor
    • Grove PIR Motion Sensor
    • Grove UV Sensor
    • Grove Servo Motor
    • GroveTemperature Sensor
    • Grove Sound Sensor
  • Arduino ino FilesClick to open the Arduino ino Files menu
    • light-sensor.ino
    • pirmotion-sensor.ino
    • moisture-sensor
    • hello-world.ino
    • uv-sensor.ino
    • servo-sweep.ino
    • temp-sensor.ino
    • sound-sensor.ino
  • STEM CoursesClick to open the STEM Courses menu
    • Simple Energy Source - Battery
    • SimpleMachines
    • STEAM 101
    • STEAM201
    • STEAM301
    • STEAM401
    • STEAM501
  • Sustainability Courses: Solar
  • Solar Light Circuit
  • Sensor 101
  • LEGO Classes
  • Drone Projects
  • 3D Printing Projects
  • Programming Resources
  • Contact Us
  • Contact BayArea Chapter
  • Bylaws
  • Thank You
  • Events Participated

pirmotion-sensor.ino

/* * PIRMotionSensor.ino * Example sketch for the PIR motion sensor * * Copyright (c) 2013 seeed technology inc. * Website    : www.seeed.cc * Author     : FrankieChu * Create Time: Jan 21,2013 * Change Log : * * The MIT License (MIT) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */  /*****************************************************************************/

//  Function: If the sensor detects the moving people in it's detecting range,

//        the Grove - LED is turned on.Otherwise, the LED is turned off.

//  Hardware: Grove - PIR Motion Sensor, Grove - LED

//  Arduino IDE: Arduino- 1.0

/*******************************************************************************/

/*macro definitions of PIR motion sensor pin and LED pin*/

//Use pin 4 to receive the signal from the motionsensor module 

#define PIR_MOTION_SENSOR 4

//the Grove - LED is connected to D7 of Arduino

#define LED 7


void setup(){  pinsInit();

}
void loop() {

    if(isPeopleDetected())

//if it detects the moving people?

        turnOnLED();

    else    turnOffLED();

}

void pinsInit(){

     pinMode(PIR_MOTION_SENSOR, INPUT);

     pinMode(LED,OUTPUT);

}

void turnOnLED(){

     digitalWrite(LED,HIGH);

}

void turnOffLED(){

      digitalWrite(LED,LOW);

}

/***************************************************************/

/*Function: Detect whether anyone moves in it's detecting range*/

/*Return:-boolean, ture is someone detected.*/

boolean isPeopleDetected(){ 

     int sensorValue = digitalRead(PIR_MOTION_SENSOR);

    //if the sensor value is HIGH? 

     if(sensorValue == HIGH) { 

        return true;//yes,return ture

     }

     else  {

         return false;//no,return false 

    }

}



Copyright 2019 Chandan Shamala Library. All rights reserved.

Web Hosting by Yahoo!

Chandler 85248
chandan@chandanshamalalibrary.org