Motor only turns in one direction, while the other is fine

I am trying to make a small 2 wheel car but one of the wheels is only turning one way. The other motor is connected to a different channel on my L298N motor driver and works fine both ways, i tried connecting another motor to the potentially faulty channel and it does the same thing - only turns when i send the letter N through the serial terminal. Should i replace the motor driver or is the issue in my code or wiring?

#include "Arduino.h"
#include <SoftwareSerial.h>

const byte rxPin = 9;
const byte txPin = 8;
int in1 = 5;
int in2 = 4;
int in3 = 12;
int in4 = 6;
SoftwareSerial BTSerial(rxPin, txPin); // RX TX

void setup() {
  // define pin modes for tx, rx:
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  BTSerial.begin(9600);
  Serial.begin(9600);
  pinMode(13, OUTPUT);

  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);

  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
  pinMode(7, OUTPUT);
}

String messageBuffer = "";
String message = "";

void loop() {
  
  while (BTSerial.available() > 0) {
    char data = (char) BTSerial.read();
    messageBuffer += data;
    if (data == 'n'){
      message = messageBuffer;
      messageBuffer = "";
      digitalWrite(in3, HIGH);
      digitalWrite(in4, LOW);
      digitalWrite(in1, HIGH);
      digitalWrite(in2, LOW);
      digitalWrite(7, HIGH);
      delay(1000);
      digitalWrite(7, LOW);
      
    } if (data == 'b'){
      message = messageBuffer;
      messageBuffer = "";
      
      digitalWrite(in1, LOW);
      digitalWrite(in2, HIGH);
      digitalWrite(in3, LOW);
      digitalWrite(in4, HIGH);
      digitalWrite(7, HIGH);
      delay(1000);
      digitalWrite(7, LOW);
      
    } 
  }
  
}

I believe that you forgot the enable pin.

Show us how it's wired.

Also take a look in this tutorial.

PS. is not the same IC but I believe that the logic is the same.

Edit:

You are using pin 7 to enable both motors.

Are 3 pins per motor as you can see in this example:

// Motor A connections
int enA = 9;
int in1 = 8;
int in2 = 7;
// Motor B connections
int enB = 3;
int in3 = 5;
int in4 = 4;

void setup() {
	// Set all the motor control pins to outputs
	pinMode(enA, OUTPUT);
	pinMode(enB, OUTPUT);
	pinMode(in1, OUTPUT);
	pinMode(in2, OUTPUT);
	pinMode(in3, OUTPUT);
	pinMode(in4, OUTPUT);
	
	// Turn off motors - Initial state
	digitalWrite(in1, LOW);
	digitalWrite(in2, LOW);
	digitalWrite(in3, LOW);
	digitalWrite(in4, LOW);
}

void loop() {
	directionControl();
	delay(1000);
	speedControl();
	delay(1000);
}

// This function lets you control spinning direction of motors
void directionControl() {
	// Set motors to maximum speed
	// For PWM maximum possible values are 0 to 255
	analogWrite(enA, 255);
	analogWrite(enB, 255);

	// Turn on motor A & B
	digitalWrite(in1, HIGH);
	digitalWrite(in2, LOW);
	digitalWrite(in3, HIGH);
	digitalWrite(in4, LOW);
	delay(2000);
	
	// Now change motor directions
	digitalWrite(in1, LOW);
	digitalWrite(in2, HIGH);
	digitalWrite(in3, LOW);
	digitalWrite(in4, HIGH);
	delay(2000);
	
	// Turn off motors
	digitalWrite(in1, LOW);
	digitalWrite(in2, LOW);
	digitalWrite(in3, LOW);
	digitalWrite(in4, LOW);
}

// This function lets you control speed of the motors
void speedControl() {
	// Turn on motors
	digitalWrite(in1, LOW);
	digitalWrite(in2, HIGH);
	digitalWrite(in3, LOW);
	digitalWrite(in4, HIGH);
	
	// Accelerate from zero to maximum speed
	for (int i = 0; i < 256; i++) {
		analogWrite(enA, i);
		analogWrite(enB, i);
		delay(20);
	}
	
	// Decelerate from maximum speed to zero
	for (int i = 255; i >= 0; --i) {
		analogWrite(enA, i);
		analogWrite(enB, i);
		delay(20);
	}
	
	// Now turn off motors
	digitalWrite(in1, LOW);
	digitalWrite(in2, LOW);
	digitalWrite(in3, LOW);
	digitalWrite(in4, LOW);
}







ah sorry that mightve been confusing but pin 7 is an led, i put it so i could see if i was getting a message received from my phone which has a bluetooth terminal app.

The photos are useless to us. Please post a photo of a hand-drawn wiring diagram, with pins and connections clearly labeled.

Try the example above.

This pics doesn't help so much.

@johnerrington yeah i put some pictures below

will i have to remove the extra headers on the sides of the middle pins on the motor controller to use the ENA pins?

Remove the jumpers ATV_A and ATV_B and connect wires to Arduino pins as shown below.

sure

is this right?

#include "Arduino.h"
#include <SoftwareSerial.h>

const byte rxPin = 9;
const byte txPin = 8;
int in1 = 5;
int in2 = 4;
int in3 = 12;
int in4 = 6;
int ENA1 = 10;
int ENA2 = 11;
SoftwareSerial BTSerial(rxPin, txPin); // RX TX

void setup() {
  // define pin modes for tx, rx:
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  BTSerial.begin(9600);
  Serial.begin(9600);
  pinMode(13, OUTPUT);

  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(ENA1, OUTPUT);

  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
  pinMode(ENA2, OUTPUT);
  pinMode(7, OUTPUT);
}

String messageBuffer = "";
String message = "";

void loop() {
  
  while (BTSerial.available() > 0) {
    char data = (char) BTSerial.read();
    messageBuffer += data;
    if (data == 'n'){
      message = messageBuffer;
      messageBuffer = "";
      digitalWrite(in3, HIGH);
      digitalWrite(in4, LOW);
      digitalWrite(in1, HIGH);
      digitalWrite(in2, LOW);
      digitalWrite(ENA1, HIGH);
      digitalWrite(ENA2, HIGH);
      digitalWrite(7, HIGH);
      delay(1000);
      digitalWrite(7, LOW);
      
    } if (data == 'b'){
      message = messageBuffer;
      messageBuffer = "";
      
      digitalWrite(in1, LOW);
      digitalWrite(in2, HIGH);
      digitalWrite(in3, LOW);
      digitalWrite(in4, HIGH);
      digitalWrite(ENA1, HIGH);
      digitalWrite(ENA2, HIGH);
      digitalWrite(7, HIGH);
      delay(1000);
      digitalWrite(7, LOW);
      
    } 
  }
  
}

i added the ENA parts

Don't apply 12 V to VIN because the regulator will overheat.

Instead use a step down to drop the voltage from external power supply to 7 - 9V.

Try the example above first then follow the pattern.

hello im back and the code that i sent worked thanks for helping out!