DC Motor only turns one direction but not the other

Battery: 12v
Adafruit DRV8871 motor drive
Arduino uno

Problem:
When i run this code, it only runs a single direction. and when i switch the HIGH to LOW, it doesnt move anything even though i want it to move it the other direction.

#define MOTOR_IN1 10
#define MOTOR_IN2 9

void setup() {
  Serial.begin(9600);

  Serial.println("DRV8871 test");
  
  pinMode(MOTOR_IN1, OUTPUT);
  pinMode(MOTOR_IN2, OUTPUT);
  
}

void loop() {
  int time = 1000;
  
  int initial = 255;

  digitalWrite(MOTOR_IN1, LOW);
  analogWrite(MOTOR_IN2, initial);
  delay(time);
  analogWrite(MOTOR_IN2, 0);
  for(int i = 255; i >= 0; i--){
    analogWrite(MOTOR_IN2, i);
    delay(5);
  }
  delay(100000);  
}

Please, refrain from creating multiple topics with the same subject.

What motor? Post a wiring diagram of your project.

Maybe look at how Adafruit suggests using this:

Your code appears to misunderstand a key concept about H-bridges.

25GA370 DC Encoder Metal Gearmotor 12V High Speed 150RPM Gear Motor with Two-channel Hall Effect Encoder for DIY Parts

for the project, it should be attached as a picture im not sure how to design a diagram

thank you i will take a look

A pencil drawing is good. Start with a box representing the Arduino, write the pins you are using, draw wires to other devices and show which pins the other devices are using. Take a photo. Post the photo.

i tried the exact wiring and code on the website, it sure does ramp up forward but doesnt go the other direction

Your drawing is missing device names, wires and pin numbers.

You must not power the motor driver with the Arduino. You must use a power supply.

Your battery pack has 8 AA batteries? Looks like only 4.

You have only half the code from the Adafruit example sketch. If you use the complete code the motor speed will ramp up in one direction, pause for one second, ramp down to zero speed, pause for ten seconds and then ramp up and down in the opposite direction.

Which type of motor you are using?
Adafruit DRV8871 driver is only for dc brushed motors.
Can you post pic of your motor.

have both forward and backwards

The code you posted does not have valid code for backwards.

I am not sure what this means. Is it a question or a statement? Did you get your motor running in both directions?

For further information, the use of the Uno 5 volts out to provide power to the motor driver, as shown in the Adafruit documentation, is not advisable. A DC motor draws too much current and the Uno cannot supply it.

Looking at your photo of your layout it appears that you have the motor driver connected properly. Are you using the coaxial connector to provide power to the Uno when not powered by the USB power?

The part I cannot understand is at the lower left of the photo. What are the wires from the Uno to the black plug going to?

when i am actually powering it,i have the 12 v batteries connected to the circular plug, after i put to code into the arduino with the usb. (also no, it doesnt go the other direction sadly :C) The circular black plug is going into the arduino to power it. if u are talking about the other rectangular looking ones, they are going into the motor.

Yeah that one is for forward. When i switch the high to low and etc, it doesnt move the other way

should support because my friend uses the same one and his moves forward and backwards properly

See post #11.