Switching a 12v dc motor

Dear friends,
I have a doubt how to -switch a motor using ic555.
when i am give input through a photoelectric sensor.. suddenly my output gets on. when i am turned of my sensor.. then the timer gets start and after few its delayed off. but i need to work like..when I am give input motor will work upto 3 sec after that turned off even my input is on. pls give me a solution..