I'm using an Adafruit V1 Motor Shield for coding two 12 volt DC motors. In my code I'm changing the set speed, but the motors still seem to be going the same speed, which is really fast, and I want them to go slow. What do I change to make my motors speed run the way I want them to run?
Here's my code below:
#include <AFMotor.h>
AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Motor test!");
// turn on motor
motor1.setSpeed(3);
motor2.setSpeed(5);
}
void loop() {
uint8_t i;
//second motor
Serial.print("tick");
motor2.run(FORWARD);
for (i=0; i<255; i++) {
motor2.setSpeed(i);
delay(10);
}
for (i=255; i!=0; i--) {
motor2.setSpeed(i);
delay(10);
}
Serial.print("tick");
motor2.run(FORWARD);
for (i=0; i<255; i++) {
motor2.setSpeed(i);
delay(10);
}
for (i=255; i!=0; i--) {
motor2.setSpeed(i);
delay(10);
}
Serial.print("tick");
motor2.run(FORWARD);
for (i=0; i<255; i++) {
motor2.setSpeed(i);
delay(10);
}
for (i=255; i!=0; i--) {
motor2.setSpeed(i);
delay(10);
}
Serial.print("tick");
motor2.run(FORWARD);
for (i=0; i<255; i++) {
motor2.setSpeed(i);
delay(10);
}
for (i=255; i!=0; i--) {
motor2.setSpeed(i);
delay(10);
}
Serial.print("tick");
motor2.run(FORWARD);
for (i=0; i<255; i++) {
motor2.setSpeed(i);
delay(10);
}
for (i=255; i!=0; i--) {
motor2.setSpeed(i);
delay(10);
}
//1 motor
Serial.print("tick");
motor1.run(FORWARD);
for (i=0; i<255; i++) {
motor1.setSpeed(i);
delay(10);
}
for (i=255; i!=0; i--) {
motor1.setSpeed(i);
delay(10);
}
Serial.print("tick");
motor2.run(FORWARD);
for (i=0; i<255; i++) {
motor2.setSpeed(i);
delay(10);
}
for (i=255; i!=0; i--) {
motor2.setSpeed(i);
delay(10);
}
Serial.print("tick");
motor2.run(FORWARD);
for (i=0; i<255; i++) {
motor2.setSpeed(i);
delay(10);
}
for (i=255; i!=0; i--) {
motor2.setSpeed(i);
delay(10);
}
Serial.print("tack");
motor1.run(BACKWARD);
for (i=0; i<255; i++) {
motor1.setSpeed(i);
delay(10);
}
for (i=255; i!=0; i--) {
motor1.setSpeed(i);
delay(10);
}
}
loop()
... what happens then?What do I change to make my motors speed run the way I want them to run?
... how is anyone supposed to guess how you want the motors to run?