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 provided624
LinkIt One Burglar Alarm

Things used in this project

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

6 projects • 153 followers
Intel Software Innovator and developer at Geek Monkey Studios. She is a Microsoft Certified Professional and C# specialist.

Comments

Add projectSign up / Login