2

I'm using Arduino and Adafruit to control 4 motors for a little robot.

I have this code example:

#include <AFMotor.h>

AF_DCMotor motor1(1, MOTOR12_1KHZ); // create motor #2, 64KHz pwm
AF_DCMotor motor2(2, MOTOR12_1KHZ); // create motor #2, 64KHz pwm
AF_DCMotor motor3(3, MOTOR12_1KHZ); // create motor #2, 64KHz pwm
AF_DCMotor motor4(4, MOTOR12_1KHZ); // create motor #2, 64KHz pwm

void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Motor test!");

  motor1.setSpeed(200);     // set the speed to 200/255
  motor2.setSpeed(200);     // set the speed to 200/255
  motor3.setSpeed(200);     // set the speed to 200/255
  motor4.setSpeed(200);     // set the speed to 200/255
}

void loop() {
  Serial.print("tick");

  motor1.run(FORWARD);      // turn it on going forward
  motor2.run(FORWARD); 
  motor3.run(FORWARD); 
  motor4.run(FORWARD); 
  delay(1000);

  Serial.print("tock");
  motor1.run(BACKWARD);
  motor2.run(BACKWARD);
  motor3.run(BACKWARD);
  motor4.run(BACKWARD);
  delay(1000);

  Serial.print("tack");
  motor1.run(RELEASE);
  motor2.run(RELEASE);
  motor3.run(RELEASE);
  motor4.run(RELEASE);
  delay(1000);


}

I want to reduce speed, because now is very fast. If I change setSpeed, the motor have no more force and don't run or not good. Do you know what I'm doing wrong?

Thanks Best regards

1
  • if reducing speed from setSpeed does not works for you, Its probably power supply/motorDC problem. Keep in minds that motor DC is not a linear actuator Commented Nov 24, 2016 at 1:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.