I want to ask you about my little project . Can I do this connection ? I dont know if the motors are suitable for 6V (4xAA) battery . I read on web that small DC motors are for 3V , I use motors from "slot car racing" and I dont know their parameters . Can I destroy them (when I will use twice voltage ) ? And what abou H-bridge ? Is L293D suitable for 2 motors . The connection with Arduino is not important for this moment.
Over-voltage on a small DC motor won't destroy it immediately. It will cause a build-up of heat that might cause plastic components to melt and possibly catch fire. If you use a 3V motor on 6V you can compensate by using PWM values only up to 128 (half scale).
The dual H-bridge should be able to handle two motors as long as the current draw doesn't exceed their limits. Connect a multimeter in series with the motor to see how much current it draws. See the datasheet for the H-bridge chip to see how much current it can handle.
I can use PWM , that sounds good . I think that I can only turn it on and off again . I followed by this site http://itp.nyu.edu/physcomp/Labs/DCMotorControl and there is only HIGH and LOW state . Can you help me with code a little ? Or it will be like that :
// only for one motor analogWrite(motorPin,128) analogWrite(motorPin2,0) // for one direction analogWrite(motorPin,0) analogWrite(motorPin2,128) // for other direction
Can I do it like this ? And what about use a resistance ? It would help too , maybe .