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?
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;
}
}
}