Stop motor after reaching switch + 2 seconds?

I'm not a pro at programming and only have a bit of experience with arduino but I'm trying to figure out how to code this... I need a motor to stop 2 seconds after a switch is thrown. I figured delay() would do this for me but it wasn't doing what I wanted it to... any ideas of how I can stop a motor some time after a switch is thrown?


It always helps if you post the code you already have.

When the switch is thrown, use the technique in the BlinkwithoutDelay example to wait for 2 seconds before going on to the next thing (in your case, stoppping the motor).

The demo several things at a time is an extended example of the BWoD technique.

When the switched is pressed record the value of millis() and then keep checking until the difference between that and the current value of millis() exceeds 2000.