Activate Stepper Motor with PIR sensor

Well, you have some logical condition when motion is detected.

And when you stop detecting the motion, you remember what time that is, and you start counting the time.
And if you detect motion, you go back to the logical condition when motion is detected.

And if 5 seconds go by, and you still don't detect motion any more, then you start driving your stepper motor.

So your system has four different states.

State 1: currently detecting motion
State 2: not detecting motion, but had motion in the last 5 seconds
State 3: running the stepper motor sequence
State 4: finished running the stepper motor sequence.

And then you implement the logical steps which cause transitions between those 4 logical states.