Arduino,pimng,motor

hi i have got a ping sensor , arduino duemilanove and a motor h bridge how ever i need help programming i need the sensor to tell the motor to turn when it gets too close say 5cm close to a object

thanks for all the help

rhys