dc motor control code example

I am looking for a web code example that will come nearest to these behaviors:
-two dc motors, moving in sync or opposite directions that will spin our bot
-a reverse/turn/go sequence when our bot hits an object

I have scoured the web but have found only bits and pieces. I am not experienced and am trying to cut and paste much as possible. It you are aware of a site that might help, please forward the address. Thanks.