Pooja Baraskar
Published © GPL3+

LinkIt One Burglar Alarm

Let us understand about PIR Motion Sensor and its working to create some cool stuffs like this.

IntermediateFull instructions provided1,098
LinkIt One Burglar Alarm

Things used in this project

Hardware components

PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1
Buzzer
Buzzer
×1
LED (generic)
LED (generic)
×1

Story

Read more

Code

Code for Burglar Alarm

Arduino
#define PIR_MOTION_SENSOR 2//Use pin 2 to receive the signal from the module 
#define Buzzer	3//the Grove - Buzzer is connected to D3 
#define LED	4//the Grove - LED is connected to D4 

void setup()
{
  pinMode(PIR_MOTION_SENSOR, INPUT);
	pinMode(Buzzer,OUTPUT);
  pinMode(LED,OUTPUT);
  
}
void loop()   
    {  
        if(isPeopleDetected())   //if it detects the moving people  
            turnOnBuzzer();  
        else  
            turnOffBuzzer();  
    }  

boolean isPeopleDetected()
    {
    	int sensorValue = digitalRead(PIR_MOTION_SENSOR);
    	if(sensorValue == HIGH)//if the sensor value is HIGH?
    	{
    		return true;//yes,return true
    	}
    	else
    	{
    		return false;//no,return false
    	}
    }
 
 void turnOnBuzzer()  
    {
      digitalWrite(Buzzer,HIGH);
      digitalWrite(LED,HIGH);
    }  
    
void turnOffBuzzer()  
    {  
      digitalWrite(Buzzer,LOW); 
      digitalWrite(LED,LOW);
     
    }

Credits

Pooja Baraskar

Pooja Baraskar

25 projects • 178 followers
Pooja Baraskar is an accomplished software engineer, inventor, and technical author with over a decade of experience in the tech industry.

Comments