Go Down

Topic: DC motors not functioning properly (Read 100 times) previous topic - next topic

givani30

I've got problems with connecting two DC motors to an arduino with an additional 9v battery. I've built an example of it in fritzing and attatched it to this post. While this scheme used to work, it is really unreliable lately, sometimes the motors will spin for a few seconds before they wont spin again. This seems to happen randomly. Does anyone know how to fix this problem so that the motors will spin consistently?


This is my source code
int motorPin = 9;
int motorPin2 = 3;
void setup()
{
  pinMode(motorPin, OUTPUT);
  pinMode(motorPin2, OUTPUT);
}
 
 
void loop()
{
  if (Serial.available())
  {
  analogWrite(motorPin, 50);
  analogWrite(motorPin2, 50);
  delay(2000);
  }
    {
  analogWrite(motorPin, 100);
  analogWrite(motorPin2, 100);
  delay(2000);
  }  {
  analogWrite(motorPin, 150);
  analogWrite(motorPin2, 150);
  delay(2000);
  }  {
  analogWrite(motorPin, 200);
  analogWrite(motorPin2, 200);
  delay(2000);
  }
  {
  analogWrite(motorPin, 255);
  analogWrite(motorPin2, 255);
  delay(2000);
  }
   }



MarkT

PP3 sized 9V batteries cannot provide enough current for motors, they struggle and voltage falls, then the
motor driver resets.  Those batteries are designed for a few tens of mA.

You need a decent battery pack that can handle the current - probably an amp or so for small motors.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy