Help with motion activated servo please.

AWOL:

Can you see where your code differs from this ?

It doesn't need fixing.
Read the source.

I have read it and see your point (and have learnt something), but I wonder if the OP knows what it is doing. Seeing the numbers involved in the code that he posted I did wonder if one of the things that he had tried was writeMicroseconds() at some time and had not changed the parameters when changing to write().

Incidentally, I wonder why the auto-switch to writeMicroseconds() is not mentioned in the reference pages.