problem with L298N and PWM Arduino

Hi,

I´m programming one car with ARDUINO UNO R3, SENSOR SHIELD V5, ONE SERVO, ONE HCSR04 AND WITH L298N I want to control the sense and speed of TWO DC GEAR MOTOR.

The power for ARDUINO and LM298N are 4 batteries of 1.5V AA. I keep the jumper of sensor shield and the jumper of LM298N because the Voltage is less tan 12V.

It Works ok with the jumper of ENA, ENB on. But, when I want to control speed with one output with PWM from Arduino (9 and 3) the DC GEAR MOTOR doesn´t move.

Why?

Because there's something wrong with your components or your wiring or your code. I can't see any of them so that's all I can tell.

Steve

Hi,

LM298N has a lot of voltage drop; we usually use 6 AA.

Here is an example that we know works:

http://arduino-info.wikispaces.com/RobotKitMenu

slipstick: Because there's something wrong with your components or your wiring or your code. I can't see any of them so that's all I can tell.

Steve

//L298N int ENA=5; //habilita motor 1 int ENB=9; //habilita morot 2 era la 3 int IN1=7; //señal motor 1 int IN2=8; //señal motor 1 int IN3=12; //señal motor 2 int IN4=13; //señal motor 2

void setup() { // put your setup code here, to run once: //Serial.begin(9600); pinMode(TriggerPin,OUTPUT); pinMode(EchoPin,INPUT); pinMode(ENA,OUTPUT); pinMode(ENB,OUTPUT); pinMode(IN1,OUTPUT); pinMode(IN2,OUTPUT); pinMode(IN3,OUTPUT); pinMode(IN4,OUTPUT); //myservo.attach(9); }

void loop() {

int cm = ping (TriggerPin,EchoPin); digitalWrite (IN3, HIGH); digitalWrite (IN4, LOW); analogWrite(ENB,55); delay(2000); analogWrite(ENB,155); delay(2000); analogWrite(ENB,255); delay(2000); analogWrite(ENB,0);

}

4 batteries 1.5V AA ==> arduino (servo,hcsr04 and arduino) + 2 dc gear motor.

terryking228: Hi,

LM298N has a lot of voltage drop; we usually use 6 AA.

Here is an example that we know works:

http://arduino-info.wikispaces.com/RobotKitMenu

ok thanks!! I´ll try power arduino+servo+hcsr04 with 1 battery 9v and power the motors with the 4 batteries. Perhaps that´s the problema. I have checked the wires and the program and I think it is ok.

I think that you may have missed Terry's point. Using the L298 motor driver, your 6V motor is getting less than 4V because the driver drops at least 2V. To compensate, the battery voltage needs to be high enough to overcome the (at least) 2V drop caused by the L298, hence the recmmendation to use 6 AA batteries (9V). Don't be tempted to use a 9V transistor battery, it will not provide enough current for a motor for long, if at all.