pir and servo help

I need help programming a pir to detect motion and rotate a servo 15-30 sec after pir no longer detect motion. If interested, please let me know how much and anything i need to know.

This is for a project with my son. I wants it to close the toilet seat after someone is done. His homework was lost in the toilet after his 2 year old brother put his homework in the toilet. I'm having a hard time trying to figure out how to program the arduino with working long hours. Any help would be great appreciated.

Sil9mm:
I need help programming a pir to detect motion and rotate a servo 15-30 sec after pir no longer detect motion. If interested, please let me know how much and anything i need to know.

I think a PIR is the wrong sensor for this. I've had quite some times that the lights in the toilet switched off (they used motion detectors to switch on the lights if anyone came to use this toilet) while sitting on the toilet taking care of business, and that timeout was way longer than 30 seconds. Waving my hand would switch it on. I suspect that more people are like me, not moving too much while taking a dump, and not enough for a PIR to continue to notice you're there.

My suggestion: use an ultrasound distance sensor. This way if there's someone on the toilet you can measure this by reduced distance - no matter how much they move, or not at all. Hang it above it or behind it, whatever convenient.

That makes a lot of sense. Thanks for the help. Ill look into that.

Does anyone want to help with the coding? I feel like im having to start all over with no time. Ive spent a couple weeks in my very little spare time trying to help my son figure out the pir. Now starting from scratch.

A PIR is much simpler than an ultrasound sensor - a PIR normally gives a simple high/low signal based on detection of movement, with an ultrasound sensor (thinking of the popular and cheap HC-SR04) you measure the time of the return trip, and calculate the distance from that.

Servo: the hard part here is in the hardware.
To close a toilet seat (that's what you want to do, right?) the servo has to be mounted at the hinge of the seat. It's going to need some serious torque to move this lid in a controlled manner: to move it down gently without it slamming down. Any idea on how you're going to mount this on your toilet? Do you have such a (water, pee, and other liquids proof!) servo already?

A simpler (but certainly less elegant) solution would be a push type solenoid, which simply provides a good push to the lid to close it. In that situation it will of course just slam down, you may have to add some rubber blocks to dampen the impact.

We have soft close toilet seats so they just need a push of about 4-5 inches and they close slowly. Ive been wrapping my head around the coding and still not any closer

I was thinking a servo to rotate 90 degrees with a wheel on the end of an arm to roll across giving more movement to push the seat passed the self close point

That should do, too. It also depends on the space you have to actually mount these things. You know that better. Just make sure it's all waterproof and cleanable.

Code is not too hard, the hardest bit is going to be to get the servo to move at a reasonable speed, which means lots of discrete steps. I'll be able to get that done.