Question on slowing down motor on motor shield

Hi,

I’m new to this and I built a small car with two motors using the Adafruit Motor Shield v1.3.

I’ve been able to move the car in all directions by changing the code in the Motor Shield Test from Adafruit’s library, but I’m trying to figure out how to have the motors move at slower speed at times (or to not move as for one command.

What I’m trying to figure out is how I change the code below to make the car move half as far (or at half the speed)?


#include <AFMotor.h>

AF_DCMotor motor3(3);
AF_DCMotor motor4(4);

void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps

}

void loop() {
uint8_t i;

Serial.print(“goforward”);

motor3.run(FORWARD);
motor4.run(FORWARD);
for (i=0; i<255; i++) {
motor3.setSpeed(i);
motor4.setSpeed(i);
delay(10);
}

for (i=255; i!=0; i–) {
motor3.setSpeed(i);
motor4.setSpeed(i);
delay(10);
}
}


Any tips would be appreciated. Thank you!

What happens if you do (for example) motor.setSpeed(50); or motor.setSpeed(200);

...R

Robin2:
What happens if you do (for example) motor.setSpeed(50); or motor.setSpeed(200);

…R

I spent too much time trying to change numbers in “for (i=0; i<255; i++)” instead of just changing that part.

Thank you!