L298N motor driver only takes IN1 and IN2 for inputs

i recently bought an L298N motor driver module and i want to use it to drive 1 motor. I am using 4.5V power supply (3 x 1.5V battery) to power the motor and logic module. The problem is that the motor spins in full power regardless if EN1 is connected to Vcc or not. IN1 and IN2 still work as intended and change the direction of the motor. Is the problem that I am using too little voltage to power the module? I used 9V power source and the motor doesnt spin at all regardless of what the pins are set to.

I also tried connecting the L298N to an Arduino Uno, but in this configuration the The motor only spins if only 1 of the IN pins are connected - if there are 2 connected it stops spinning.Use code tags to format code for the forum The EN1 still does not have any effect on the motor in this scenario.

void setup() {
  // put your setup code here, to run once:
  pinMode(9, INPUT);
  pinMode(8, INPUT);
  pinMode(7, INPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(9, 0);
  analogWrite(8, 0);
  analogWrite(7, 0);
}


^^ module not connected to Arduino


^^module connected to Arduino

Hi, @dit
Welcome to the forum.

Can you please post your complete code?

Can we please have a circuit diagram?
An image of a hand drawn schematic will be fine, include ALL power supplies, component names and pin labels.

Also.
pins 7, 8, 9 are to be configured as OUTPUT not INPUT.
They OUTPUT the controllers signals to the module.
Have you got the gnd of the UNO connected the gnd of the modue?

Thanks.. Tom... :grinning: :+1: :coffee: :australia:
PS, PLEASE it is essential we have your complete code and a readable schematic.

That IS my complete code. I was just trying to get the motor to spin to see if it worked (It did not). The errors in my code are there because I was screwing around trying to see what worked...my bad for not posting the correct code. Here.

void setup() {
  // put your setup code here, to run once:
  pinMode(9, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(7, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(9, 200);
  analogWrite(8, 1);
  analogWrite(7, 0);
}

Also, how do I make a circuit diagram? Is there a website I can use to make a good one?
Thanks

Hi,

An image of a hand drawn schematic will be fine, include ALL power supplies, component names and pin labels.
Also change these;

void setup() {
  // put your setup code here, to run once:
  pinMode(9, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(7, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  analogWrite(9, 200);
  digitalWrite(8, 1);
  digitalWrite(7, 0);
}

Tom... :grinning: :+1: :coffee: :australia:

Hi,
I have drawn up a diagram for the 2nd scenario where I try to sue the Arduino to control the L298N module. Excuse my drawing skills as this is my first time drawing a schematic or anything like this. I hope you can use this in reference with the image that i have given in the 1st post to help me.

Thanks a lot

Hi,
Thanks, the circuit is fine.
Have you tried the modified code?

Does your motor run okay when connected directly to the motor?
You may also need to connect 5V from the UNO to 5V on the module.

Thanks.. Tom.. :grinning: :+1: :coffee: :australia:

Hi, sorry for the late reply. I've been busy with other things and my motivation to do Arduino stuff hasn't been very high recently. Anyway, can you be a bit more specific about what you said pls?
Not sure what you mean by
"Does your motor run okay when connected directly to the motor?
You may also need to connect 5V from the UNO to 5V on the module."
Thanks

Hi,

Sorry I didn't read what I wrote properly.

Does your motor run okay when connected directly to the 4.5V power supply?

Tom... :grinning: :+1: :coffee: :australia:

Yea it runs well on 4.5V power supply. when connected to the module it also runs fine as long as in1 and in2 are connected to 4.5V also (not arduino pins, just battery).

Hi,
Have you tried the Keystudio sites example, even though its for two motors, it should still run one.

https://wiki.keyestudio.com/Ks0063_keyestudio_L298N_Motor_Driver_Board_Module

Note that they have also connected 5V from the UNO to the 298 module.

Thanks... Tom... :grinning: :+1: :coffee: :australia:

thanks, ill try this when i have the time and get back to you.

hey, it seems my project is working now for some reason. I think the reason that it is working is because i was using a 9V power source rather than a 4.5V one. the only connections i need are en1, in1, in2, and vcc + gnd. thanks for your help tho

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.