Help with motion activated servo please.

wildbill:
In that case it sounds like you will need a time based approach - the automatic door thing suggests that on movement detection, you wish to move the servo, have it stay for a while & then return to the default position.

I'd suggest that you drop the delays and record the time using millis every time you see movement. In addition when that happens, move the servo to the "door open" position - if it's already moved or moving, no harm done.

When you haven't seen movement for a while, return to your start position. This way, the system will react quickly to movement when needed, but not react to rapid changes in PIR state.

Thank you! That sounds ideal, I'll read up on it now and report back how I get on.

PaulS:

When it detects a movement (each time something passes the sensor).

The thing is a sensor reports movement by setting the pin LOW. If you detect when the pin CHANGES to LOW, rather than IS LOW, you'll stop the servo from moving more than once.

Look at the state change detection example.

Thanks for that! That explains a lot, I'll study the state change example and review my code.

Thanks again guys, much appreciated.