0

My code is getting uploaded to arduino without problem but still my motor is not moving when i connect it to the motor driver shield. I am supplying 6V battery to the shield which is connected to dc motor at M2

What could be the problem?

Code:-

#include <AFMotor.h> //import your motor shield library

AF_DCMotor motor2(2,MOTOR12_2KHZ); // set up motors.
AF_DCMotor motor3(1, MOTOR34_1KHZ);

void setup() {
  Serial.begin(9600); // begin serial communitication  
  Serial.println("Motor test!");
  motor2.setSpeed(105); //set the speed of the motors, between 0-255
  motor3.setSpeed(105);  
}

void loop() {
   motor2.run(FORWARD); 
   motor3.run(FORWARD);
  } 

image of circuit

  • Do you have a picture of your setup? You might also find this post on our Meta site helpful: How to ask a good question for Arduino Stack Exchange. – sempaiscuba Oct 28 '18 at 17:48
  • There is a large voltage drop to the motors. It is meant for 12v and (very) small 12v motors. – Jot Oct 28 '18 at 17:55
  • so it means if i supply 12v then it will work right? but the motor works with 5v also – Sultan Morbiwala Oct 28 '18 at 18:21
  • The l293d outputs a voltage to a motor of 2.6v lower than the power supply. For 12v you need 12v motors. – Jot Oct 30 '18 at 2:31
2

I cannot tell all of your connections from the photo, but I'm guessing you're supplying power to the Arduino through its power connector and also to the motors, both from the battery. The power connector on the Arduino is specified for 7-12v because the kind of voltage regulator it has needs that 2v difference to operate properly. You're kind of at the edge by supplying 6v, and when the motors come on, their current draw will cause the 6v battery voltage to drop somewhat. It probably drops below the regulator's ability to supply 5v from it, shutting down the Arduino.

Adding one more cell to your battery will give you 7.5v (5x1.5v) and will may be enough to run the Arduino and the motors. Two more cells would work even better. (Don't make the mistake of trying the small 9v batteries with snap-clips on top - their utterly incapable of supply the current your motors need).

  • cool, i will try to supply more power and see. thanks – Sultan Morbiwala Oct 30 '18 at 16:14

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.