Time period of a Passive Infrared Sensor (PIR)

Hello Guys, i need your help with this. I want to read an analog PIR sensor, and whenever the sensor reads a specific value for a short period of time say a minute, i want it turn on a buzzer. Also whenever the sensor reads this same specific value for a long period of time say 4 minutes, i want it to turn on a buzzer at the same time send an SMS message. Thanks.

Please post what you have tried already. Perhaps a program that prints a message to Serial when the PIR value is above a certain value as a start.

A link to the sensor would be useful, too. Typically, PIR sensors are digital. There is movement, or there isn’t. What does an analog PIR sensor tell you?

Okay guys, the sensor is an infrared sensor not a PIR sensor. And i have also attached the picture. This is what i have done earlier on in my codes.

/* code begins

if(pirValue >= 500) //if the analog value is equal or adove 500
{
int newmillis1= 0;
while(newmillis1 <= 6)//
{
digitalWrite(buzzer,HIGH);
newmillis1=millis()/1000;
lcd.clear();
lcd.setCursor(4,0);
lcd.print(“WARNING!!”);
lcd.setCursor(2,1);
lcd.print(“OBSTRUCTION”);
lcd.blink();
delay(100);
}
if(newmillis1 >= 13) {
digitalWrite(buzzer,LOW);
GSM_pir();
}

*/code ends

I hope this helps. If you need any clarification please let me no. Thankx

infrared.jpg

If you need any clarification please let me no

Personally I would like to see the whole program.

But starting with what I can see

 while(newmillis1 <= 6)//
 {
    digitalWrite(buzzer,HIGH);
   newmillis1=millis()/1000;

6 seconds after the program starts to run newmillis1 will be greater than 6 and will start that way for nearly 50 days. Will that be a problem ?

Actually, the way he has written his program, newmillis is only defined within the if statement, which is presumably inside his loop( ) function, athough we can’t tell that for sure.

So, every time that if statement is executed, if pirValue is greater than 500, zero will be assigned to newmillis, and the following if statement ( newmillis < 6 ), will always be true.

newmillis is only defined within the if statement,

Yes, I had missed that. Wrong either way then.