I'm playing around with the rover kit from DF Robot Shop (http://www.robotshop.com/productinfo.aspx?pc=rb-rbo-33). I'm running the code essentially as described in the rover's instruction manual.

I notice that when I give the command for the rover to turn right or left, it spins around in clockwise or counterclockwise circles, respectively. Rather than spinning around endlessly, I really want it to spin 30 degrees left or right, stop, and wait for the next command.

The kit comes with what look like pretty basic 5V DC motors. I think I need to re-write the code so that the motors only spin for 300 or 400 milliseconds before stopping and waiting for the next command. I'm not sure how to do that. I've looked at some of the "timer" libraries on the Arduino forum but they dont' really appear to be what I'm looking for.

Here's the code I'm running. Any general suggestions would be great!

//Control the Rover with four over-serial commands: left, right, forward, backwards.//Modified the forward, left, right and backward commands to make the rover go//in the desired direction.

If that doesn't work, you might try adjusting the speed of the motors instead of how long the motors run for.

Up in the void loop you initiate the speed of both motors. Interestingly, the left motor is set at speed 250 out of 255 and the right motor is set at 255 out of 255. So if I'm reading this correctly, your right motor is moving faster than the left motor. Not sure if that's intentional because of the chassis, or it your robot is running in circles.

I tried adding another "while" statement incorporating millis() to make the rover stop turning left after 300 milliseconds. I eventually got the compiler to run through the code without errors, but the rover doesn't actually behave differently. It still turns in endless counter-clockwise circles. I think I need some way to start the millis() counter once I send the "left" command over the serial port.

Here's my code below:

@ Schmidtn

Thanks for your suggestion about the motor speed. I do have the motors set at different speeds. They are pretty cheap and the rover tends to turn right when both motors are running at full speed. I set the left speed motor a bit slower so that the rover basically goes straight in the forwards and backwards modes.

//Control the Rover with four over-serial commands: left, right, forward, backwards.//Modified the forward, left, right and backward commands to make the rover go//in the desired direction.

I think I need some way to start the millis() counter once I send the "left" command over the serial port.

No. I can assure you that you do not need to restart the millis() counter. If you call your girlfriend (or boyfriend) and she/he says call me back in an hour, do you need to reset your watch? No, of course not. You simply note the current time. At many points in the future, you check the current time, and see if "now" minus "then" is greater to or equal to an hour. If so, you make the call again.