// Define BTS7960 input pins
const int RPWM = 5;     // Right IN (PWM)
const int LPWM = 6;     // Left IN (PWM)
const int R_EN = 7;     // Right INH (Enable)
const int L_EN = 8;     // Left INH (Enable)

void setup() {
  // Set control pins as outputs
  pinMode(RPWM, OUTPUT);
  pinMode(LPWM, OUTPUT);
  pinMode(R_EN, OUTPUT);
  pinMode(L_EN, OUTPUT);

  // Enable both sides
  digitalWrite(R_EN, HIGH);
  digitalWrite(L_EN, HIGH);
}

void loop() {
  // Rotate motor forward
  analogWrite(RPWM, 200);  // PWM signal (0–255)
  analogWrite(LPWM, 0);
  delay(3000);  // Run for 3 seconds

  // Stop motor
  analogWrite(RPWM, 0);
  analogWrite(LPWM, 0);
  delay(1000);

  // Rotate motor in reverse
  analogWrite(RPWM, 0);
  analogWrite(LPWM, 200);
  delay(3000);

  // Stop motor
  analogWrite(RPWM, 0);
  analogWrite(LPWM, 0);
  delay(1000);
}
