I have written a simple code that controls the motors on my tank using the Arduino mega. The code turns on both motors in a forward direction for two seconds then turns off for a second, then backwards for two seconds then off for a second.
I then got into the left right control of the motors. The simplest way to make it turn left and right is to make one motor turn off and keep the other one on. To turn right you turn off the right motor forcing the robot right, and the opposite to turn left. A more advanced way to turn left and right is to turn the motors in opposite directions. to turn left you keep the right motor going forward and turn the left motor in reverse.