I have a question about programming code that I would like to ask you. Thank you

If it doesn’t matter what kind of motor or motor driver it is, is this logic correct?

#include "HX711.h"

const int DT_PIN = 5;
const int SCK_PIN = 6;
const float SCALE_FACTOR = -2.85;

const int buttonPin1 = 2; 
const int buttonPin2 = 3; 

const int motorOutExtend = 8; 
const int motorOutRetract = 9;

HX711 scale;

void setup() {
  pinMode(buttonPin1, INPUT_PULLUP); 
  pinMode(buttonPin2, INPUT_PULLUP); 

  pinMode(motorOutExtend, OUTPUT); 
  pinMode(motorOutRetract, OUTPUT); 
  Serial.begin(9600);

  scale.begin(DT_PIN, SCK_PIN);
  scale.set_scale(SCALE_FACTOR);
  scale.tare();
}

void loop() {
  float weight = scale.get_units(1);


  if (weight >= 25830 && digitalRead(buttonPin1) == LOW) {
    digitalWrite(motorOutExtend, LOW);
  } else {
    digitalWrite(motorOutExtend, HIGH);
  }


  if (weight <= 2922 && digitalRead(buttonPin2) == LOW) {
    digitalWrite(motorOutRetract, LOW);
  } else {
    digitalWrite(motorOutRetract, HIGH);
  }
}