Help please with small motor timing script

Hi everyone. I am absolutely amazed at the arduino community and hoped someone could help a simpleton like me. My girlfriends son has a school project and I am helping him build a castle. We wanted to add a motor to pull up a draw bridge. It's a small mini type castle so I found a small dc motor in something I had but hoped I could use a arduino mini or nano to make it run for a few seconds, if that.

Basically, my idea was maybe to have a laser/optical trigger. A small soldier type character goes past the entrance and the draw bridge goes up.

So something crosses the optical field, the motor turns on for a few seconds, then turns off abruptly, and stays off until tripped again.

Can anyone help me with this code? I didn't think I would need the motor shield since it would only run for a few seconds at a time at most, and even then wouldn't run many time or have any load on it.

Thanks in advance!!!

You DO need a motor shield. Try using a servo instead!

Mark

In stead of having the motor run for a set time, it is much better to have a sensor that senses when the bridge is up.

Just a simple photo interupter switch og a microswitch with a lever or whatever can be fitted.

Oh that sounds really good. I'll have to take a look, but would you know how to write the initial script to turn the motor on? I'm guessing the switch would have to be recognized by the code too though right?