You can use analogWrite to control the motor speed. Make sure you use one of the PWM enabled pins. Note also that you'll need a mosfet to control the power from your battery - the Arduino won't be able to source it. Google arduino mosfet PWM for guidance.