0

My code uploads to Arduino but the motor is not moving when I connect it to the L293d motor driver shield. I am supplying 12V 2A to the shield through an adapter, connected to dc motor at M2. tThis is the code I am using

#include <AFMotor.h>

AF_DCMotor motor(2);

void setup() 
{
  //Set initial speed of the motor & stop
  motor.setSpeed(200);
  motor.run(RELEASE);
}

void loop() 
{
  uint8_t i;

  // Turn on motor
  motor.run(FORWARD);
  
  // Accelerate from zero to maximum speed
  for (i=0; i<255; i++) 
  {
    motor.setSpeed(i);  
    delay(10);
  }
  
  // Decelerate from maximum speed to zero
  for (i=255; i!=0; i--) 
  {
    motor.setSpeed(i);  
    delay(10);
  }

  // Now change motor direction
  motor.run(BACKWARD);
  
  // Accelerate from zero to maximum speed
  for (i=0; i<255; i++) 
  {
    motor.setSpeed(i);  
    delay(10);
  }

  // Decelerate from maximum speed to zero
  for (i=255; i!=0; i--) 
  {
    motor.setSpeed(i);  
    delay(10);
  }

  // Now turn off motor
  motor.run(RELEASE);
  delay(1000);
}

[connectionsadapter i am using

1
  • does the motor spin when connected directly to the power supply? – jsotola Aug 11 '20 at 17:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.