RC-car motor help.

Hi! I'm pretty new at this so bare with me on this one :slight_smile:

I'm trying to use the motor shield to power my rc-car.
When i run my code all it does is sounding "beeeeep" .. guessing its not getting enough power?
The battery alone can run the motor no questions since it was used while the rc-car was original.
It has 7.4V and 5300mah.

The code I'm using is from some example i found and modified a bit so its not optimal I think:

//int pwm_a = 10; //PWM control for motor outputs 1 and 2 is on digital pin 10
int pwm_a = 3;  //PWM control for motor outputs 1 and 2 is on digital pin 3
int pwm_b = 11;  //PWM control for motor outputs 3 and 4 is on digital pin 11
int dir_a = 12;  //dir control for motor outputs 1 and 2 is on digital pin 12
int dir_b = 13;  //dir control for motor outputs 3 and 4 is on digital pin 13


void setup()
{
  pinMode(pwm_a, OUTPUT);  //Set control pins to be outputs
  pinMode(pwm_b, OUTPUT);
  pinMode(dir_a, OUTPUT);
  pinMode(dir_b, OUTPUT);
  
//  analogWrite(pwm_a, 200);        
  //set both motors to run at (100/255 = 39)% duty cycle (slow)  
  analogWrite(pwm_b, 200);
  
}

void loop()
{

  digitalWrite(dir_b, LOW);  //Set motor direction, 3 high, 4 low
  
  delay(5000);
  
 
  //set both motors to run at 100% duty cycle (fast)
  analogWrite(pwm_b, 255);
  
  delay(5000);
  

  digitalWrite(dir_b, HIGH);  //Reverse motor direction, 3 low, 4 high
  
  delay(5000);
  
  //set both motors to run at (100/255 = 39)% duty cycle   
  analogWrite(pwm_b, 100);
  
  delay(5000);
}

Which motor shield are you using?

I'm using Arduino Motor Shield rev 3

Valleion:
I'm using Arduino Motor Shield rev 3

That uses the SMT version of the L298 - which can only supply up to 2A of current per on-board h-bridge (unless you parallel the two bridges, in which case it can supply 4A). Note that these values are only possible with a fairly large heatsink on the chip, which that board doesn't have.

You should also be aware that you will drop around 2 volts or so using the L298, so if you want your motor to run at the speed it was before, you need a higher voltage battery. Also, what is the stall current and free-running current of your motor? This is very important; if the stall current is higher than than what the L298 can supply, then it might not be able to start rotating. The free-running current will be less than the stall current, so will the "loaded" current (which will be higher than the free-running current). You need to know all of these in order to know if the h-bridge will work (as well as whether the h-bridge is sized properly; with that bridge, you could probably get away with a motor that only needed about 1A of current - it would run hot, but likely not need a heatsink - though it would be better if it had one; if however your motor needed 1.75A of current, you would want to put a heatsink on it - perhaps with active forced cooling with a fan).

Also - see those alligator clips you are using - those things are notorious for having high resistance, especially in motor driving circuits. The clips don't make a perfect contact, and depending on how cheap they are, the wires in them may only be a few strands wrapped around the clips (not even soldered!). They are generally no where near what is really needed for the motor connection (you want low-resistance connections; soldered, crimped, or at least screwed down is best - and you want to match the same gauge of wire that the motor already uses).

OK! you gave me a lot to think about :slight_smile: Thanks for the answer and bringing me some clarity!

uses the SMT version of the L298

A surface mount L298 ??? The only justification for these old chips is a dip socket version, so you can throw it away if it burns out.
Perhaps sale of these boards should be accompanied by a surgeon general's warning :wink:

Well - the standard multiwatt L298 that you do see - the thru-hole part - isn't DIP socket compatible (one row of pins is offset by 0.05" from the other - though the pin spacing of each row is 0.1" - why they did that, I don't know). But yeah - thru-hole is nice. It'd be nice if there were an easy thru-hole "high-current" mosfet driver IC. There are few SMT h-bridges out there that don't look insanely difficult to solder...