L298n cannot run 2 motors at the same time?

Hey, this is my code

int input1 = 5;
int input2 = 7;
int enableA = 6;
int input3 = 10;
int input4 = 12;
int enableB = 11;

void setup() {
  pinMode(input1, OUTPUT);
  pinMode(input2, OUTPUT);
  pinMode(enableA, OUTPUT);
  pinMode(input3, OUTPUT);
  pinMode(input4, OUTPUT);
  pinMode(enableB, OUTPUT);
  analogWrite(enableA,255);
  digitalWrite(enableA, HIGH);
  analogWrite(enableB,255);
  digitalWrite(enableB, HIGH);
}
void loop() {
  
  digitalWrite(input1, HIGH);
  digitalWrite(input2, LOW);
  digitalWrite(input3, HIGH);
  digitalWrite(input4, LOW);
  delay(2000);

}

I can't see anything wrong with it but when I run it on my RC tank, left side goes forward while the other side is not moving and then vice versa after 2 seconds. Didn't I program it to run both motors forward at the same time? Is this a problem with not enough power?

Well without the context of the schematic it is hard to say much.
What I can say is that this sketch sets some lines to one state and then does nothing about changing those states, in other words once set up it does nothing. s that what you want?

Why are your pins called input1 etc.. when they are clearly outputs? Variable name should reflect what is happening to avoid confusion.

Grumpy_Mike:
Well without the context of the schematic it is hard to say much.
What I can say is that this sketch sets some lines to one state and then does nothing about changing those states, in other words once set up it does nothing. s that what you want?

Why are your pins called input1 etc.. when they are clearly outputs? Variable name should reflect what is happening to avoid confusion.

Opps. Sorry kinda missed that, I got the fact that they are inputs in my head but not for the variable name.

Heres the revision with more info:

int output1 = 5;
int output2 = 7;
int enableA = 6;
int output3 = 10;
int output4 = 12;
int enableB = 11;

void setup() {
  pinMode(output, OUTPUT);
  pinMode(output2, OUTPUT);
  pinMode(enableA, OUTPUT);
  pinMode(output3, OUTPUT);
  pinMode(output4, OUTPUT);
  pinMode(enableB, OUTPUT);
  analogWrite(enableA,255);
  
  analogWrite(enableB,255);
  
}
void loop() {
  digitalWrite(enableA, HIGH);
  digitalWrite(enableB, HIGH);
  digitalWrite(output1, LOW);
  digitalWrite(output2, HIGH);
  digitalWrite(output3, LOW);
  digitalWrite(output4, HIGH);
  delay (2000);
  

}

How it is connected:

Arduino : L298n

Digital 5 to Input1 (pin 5)
Digital 7 to Input2 (pin 7)
Digital 6 to EnableA (pin6)
Digital 10 to Input3 (pin 10)
Digital 12 to Input4 (pin 12)
Digital 11 to EnableB (pin11)
5v to logic supply (pin 9)
Gnd of Arduino to battery negative side to Gnd of l298n (pin 8 )

Output1 and 2 (l298n) to DC motor 1
Output3 and 4 (l298n) to DC motor 2

I am quite certain that I have wired everything up correctly but for some reason only motor 2 runs when it runs through my program. Output1 and 2 can never run motor 1. Does this mean I have fried my l298n? I am using 2 D cell batteries for the power supply (3v stacked together). These are the same batteries used for running these motors in the original kit before any modification. I am modifying this kit for my project : http://www.tamiyausa.com/product/item.php?product-id=70107 I have checked for any loose wires and made sure the l298n have all the pins contacting the breadboard but no luck. As a side note, I have tried changing up the wiring and can confirm that the motors do work and the arduino was not damaged, so does this really mean the l298n was damaged?

Its not even about that the l298n cannot run 2 motors concurrently anymore, Output1 and 2 cannot drive a motor no matter what I try.

Your problem is you haven't read the datasheet for the L298 (or, if you have, you need to re-read it):

See page 3/13. Note the table for "Electrical Characteristics".

See Vs - it says it's minimum value is Vih + 2.5. Look at Vih - this is your "input high voltage" - since the Arduino outputs 5 volts as a "high value" (within the range of Vih), what do you think Vs can be, at minimum?

You might also note the need in the "Pin Functions" table (above "Electrical Characteristics") for pins 9 and 4 to have a 100nF cap between the pin and ground (these are decoupling caps and are important for proper operation of the IC - otherwise problems may crop up that look like ghosts).

Your code and circuit otherwise, I think, is OK.

Have you got pin 1 of the L298A connected securely to motor supply ground, either directly or through a small resistor (1 ohm or less)?

You will need to power the L298A from more than 3v, because the voltage lost in the L298A between the power supply and the motor can be as much as 3.2v at 1A.

Thanks for the tip, I connected a 9v battery and everything works now. TYTY