Hello
@Beja
As I said in the PM, I've tested this code with both the SR501 and SR505, the results were basically the same (as far as I'm concerned). The reason why I used the SR501 image above is simply because Fritzing does not have the SR505 image as standard (otherwise I would have used the SR505 image).
The SR505 has a re-sense time delay of 8 seconds +/- 30%, I'm setting the code delay above to 10 seconds which is more than enough time according to both my SR501 and SR505 tests.
Anyway, I've updated the code above to both slow down the servo rotation speed and to also stop rotating the servo (stop closing the door) if motion is detected whilst the rotating/closing, thus nobody would get chopped in half
I have a question for you, are you 100% sure that your hardware is working correctly???
I'm sending you a PM...