Go Down

Topic: L298n Problems (Read 471 times) previous topic - next topic

tawfeeq

Hi i'am a newbie when I comes to the arduino.For some reason the motors won't turn on when connected to the L298n. I'am wondering if it is a problem with the way I wired the controller and the arduino(Battery pack is in breadboard, motor controller and arduino is powered by breadboard) or my code.
Code:
//Motor A
int enA=9;
int in1=8;
int in2=7;
//Motor B
int enB=3;
int in3=5;
int in4=4;

void setup() {
  pinMode(enA,OUTPUT);
  pinMode(enB,OUTPUT);
  pinMode(in1,OUTPUT);
  pinMode(in2,OUTPUT);
  pinMode(in3,OUTPUT);
  pinMode(in4,OUTPUT);
}

void loop() {
  //Turn on motor A
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);
  analogWrite(enA,200);
  //Turn on motor B
  digitalWrite(in3, HIGH);
  digitalWrite(in4, LOW);
  analogWrite(enA,200);
  delay(2000);
 
 
}

terryking228

Hi, Please read this page about how to ask questions and show code here:

http://forum.arduino.cc/index.php?topic=149020.0

What voltage are you supplying to the L298N?

What motors? What motor voltage/current ratings?
Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

tawfeeq

My battery pack is 9 volts.

terryking228

Hi, Not sure about your particular L298N module. Can you point to a photo? On the ones I use there is a small white button:

---------------------( COPY )---------------------
NOTE! There is a small white button switch next to the blue power terminal board. SIGH! Some need to be UP and some need to be DOWN to power the motor driver. After you plug in the battery cable, look for a red led on the motor driver. Push the switch to the position where an led lights up. NOTE: You can also use the switch to turn the motors off temporarily to upload a new sketch.
-----------------( END COPY )----------------------
Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

slipstick

Exactly what sort of 9V battery? If it's one of those rectangular PP3 types then that's your answer. They will not provide nearly enough current to run motors.

And connecting relatively high power things like motors via a breadboard is also a bad idea. Many breadboards can only tolerate very low currents.

Steve

tawfeeq

Yes it's a rectangular pp3, So i'am guessing that I need a new power source or should i try not using the bread board?

tawfeeq

Image of the motor controller is attached

MarkT

Please provide _full_ details of all the hardware (at least as much info as you have!).

You've not yet said what motors are involved, we have _no idea_ at all if they are suitable for an L298
in the first place.   We can only go by the information you post...
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

tawfeeq

I'am using the generic arduino motors 3-6v(they are yellow)
An arduino mega 2560
A 9v battery pack

slipstick

Yes it's a rectangular pp3, So i'am guessing that I need a new power source or should i try not using the bread board?
Try 6 x AA cells in a holder or a 9V power supply with at least 2A. The Arduino can be powered via the breadboard but the 9V should also ideally be connected directly to the motor driver board's terminals.

Steve

tawfeeq

I just tried it and  i still have the same problems

slipstick

I just tried it and  i still have the same problems
What "it" did you try exactly?

Please post a picture showing clearly all the components and how everything is connected.

Steve

Go Up