I'm using the Adafruit motor shield to control two brushed motors for propulsion on a voice controlled robot. The tutorial says to put this in void setup:
motor1.setSpeed(255); // number is changeable, 0 is stop, 255 is full speed
motor2.setSpeed(255);
I want to be able to vary the speed, example: "ahead full", "ahead one third" etc, for which I would designate in the code appropriate numbers between 0 and 255, but this would be done in the loop portion of the code where I define the various functions. example:
void aheadOneThird(){
motor1.setSpeed(85);
motor2.setSpeed(85);
motor1.run(FORWARD);
motor2.run(FORWARD);
delay(1000); //run time before rechecking sensors and command changes
}
void aheadFull(){
motor1.setSpeed(255);
motor2.setSpeed(255);
motor1.run(FORWARD);
motor2.run(FORWARD);
delay(1000);
}
Would this work or must setSpeed be done in setup? If it must be done in setup, is this number changeable (outside of changing it in the IDE, recompiling and reloading it) if it's in the setup portion of the code?
regards, Richard