the most problem with beginner is to not getting the info of the sensor state..
active state or passive state.
firstly needed to chick at as the sensor is active or passive because it's impact the whole code and function of the project..
like
int val=DigitalRead(sensor) ;
Serial.print(val);
it will show the state of sensors..
as if at detect it's show 0 or 1.
Are you sure? Looks to me more like it will c++ while there's motion.
adafruit's example uses a state variable pirState over and above just the state of the pin, and can therefore log new motion. You code looks like theirs (hers?) with parts missing.
But I can't test it: the dog chewed the Fresnel lens half-a-ping-pong-ball thingy on my only pir sensor.
It counts roughly the seconds that the PIR sensor's output is HIGH.
This is only very loosely related to their being motion (the PIR sensor remains activated for some time after there's no more motion detected), and barely related to the number of individual motion events.
Quite a few of such sensors are active LOW, using an open collector output.
just add a variable true if it's been counted. Than insert in you code "if true" before you ask "if high". you need to set the variable too false when the sensor is low.