Dual H-Bridge Motor Driver - L298N not working properly

Hi there, am very new to the electronics community, I recent bought my first arduino. I wanted to build me own RC car, so I bought Dual H-Bridge Motor Driver L298N Module from ebay (http://www.ebay.co.uk/itm/Dual-H-Bridge-Motor-Driver-L298N-Module-For-Arduino-PIC-DC-Stepper-L298-Board-/251291436187?pt=UK_BOI_Industrial_Automation_Control_ET&hash=item3a8223049b)

I think I have connected everything correctly but somehow the 2 dc motors connected to the motor driver don't seem to move, I have tried a 9v battery to power the motor shield but doesn't seem to do anything. I used this diagram do the connection to the arduino http://i.imgur.com/JCBcSfL.jpg
The arduino itself has it own 9v battery powering it. I have checked both motors and they work fine. when i switch on the rc car the led on the motor shield blinks but the motors just don't move. Is the power to the motor shield too low?

Images of the rc car
Imgur
Imgur
Imgur
Imgur
Imgur
Imgur

The code am running on the arduino

//motor A
int dir1PinA = 2;
int dir2PinA = 3;
int speedPinA = 9;

//motor B
int dir1PinB = 4;
int dir2PinB = 5;
int speedPinB = 10;

unsigned long time;
int speed;
int dir;

void setup(){

pinMode(dir1PinA,OUTPUT);
pinMode(dir2PinA,OUTPUT);
pinMode(speedPinA,OUTPUT);
pinMode(dir1PinB,OUTPUT);
pinMode(dir2PinB,OUTPUT);
pinMode(speedPinB,OUTPUT);
time = millis();
speed = 0;
dir = 1;

}

void loop(){

analogWrite(speedPinA, speed);
analogWrite(speedPinB,255 - speed);

//set direction
if(1 == dir){
digitalWrite(dir1PinA, LOW);
digitalWrite(dir2PinA, HIGH);
digitalWrite(dir1PinB, HIGH);
digitalWrite(dir2PinB, LOW);
}else{
digitalWrite(dir1PinA, HIGH);
digitalWrite(dir2PinA, LOW);
digitalWrite(dir1PinB, LOW);
digitalWrite(dir2PinB, HIGH);
}

if(millis() - time > 5000){
time = millis();
speed += 20;
if(speed > 255){
speed = 0;
}
if(1 == dir){
dir = 0;
}else{
dir = 1;
}
}

}

What makes you think it wasn't working properly?
Those drivers have large voltage drops - it may be your motors simply aren't getting enough volts - have you measured the voltage at the motors?

Please use code tags when posting code.

Thanks for the reply, I used a digital multimeter to measure the voltage going into the motor. it goes upto 0.36v then drops. does that mean there isn't enough voltage going into the motors? and how much voltage do you recommend to get it working?

What voltage is across the motor terminals when they are working fine? Also what current do the motors draw when working?

...R

Hi Raphael,
Looking at your images, it looks like your only using 3x AA batteries, with about a 1.5V voltage drop across the H bridge in the L298, that don't leave much for your motors. I use 6 x AA (7.2V) to drive the motors then a 5 Volt reg to supply the logic and Arduino. Or plug 7.2v into Arduino power socket and take motor power from Vin on the Arduino.

I am building my 4th or 5th robot-buggy, but this is my first Arduino project, in a previous life I used Picaxe micros, but I am very new to C programming only a few weeks, here's a Picture.. It's a bit of a mess until I build or buy a suitable motor driver, etc...

Hope it helps...

Regards

Mel.

Hi, Cactusface , thanks for the reply. I tried your suggestion and it worked. I used a 6 x AA to power the motor shield. Thanks again :slight_smile:

Sorry for the late reply.

Where is the motor power coming from? Not the 5V pin I hope.

outsider:
Where is the motor power coming from? Not the 5V pin I hope.

No, if you look at the images posted you'd know that...

My feeling is the 3 AA cells in question are cheap and nasty if them can only get 0.36V out of the L298,
for motors you need high current cells, preferrable ones with a datasheet so you can check the maximum
current capability.

A small 2S LiPo pack would be much better I reckon.

MarkT:
No, if you look at the images posted you'd know that...

The images from 5 years ago?

...R