Tower Crane: control 4 dc motors

Hi,
Try this code with post #59 diagram, BUT connect EN1 to pin 9, pin 7 is not a PWM pin.

/*
 * Created by ArduinoGetStarted.com
 *
 * This example code is in the public domain
 *
 * Tutorial page: https://arduinogetstarted.com/tutorials/arduino-dc-motor
 */

// constants won't change
const int ENA_PIN = 9; // the Arduino pin connected to the EN1 pin L298N
const int IN1_PIN = 6; // the Arduino pin connected to the IN1 pin L298N
const int IN2_PIN = 5; // the Arduino pin connected to the IN2 pin L298N

// the setup function runs once when you press reset or power the board
void setup()
{
  Serial.begin(9600);
  Serial.println("Setup Running");
  // initialize digital pins as outputs.
  pinMode(ENA_PIN, OUTPUT);
  pinMode(IN1_PIN, OUTPUT);
  pinMode(IN2_PIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop()
{
  Serial.println("Top Of Loop");
  delay(250); //for diagnostic reasons.
  digitalWrite(IN1_PIN, HIGH); // control motor A spins clockwise
  digitalWrite(IN2_PIN, LOW);  // control motor A spins clockwise
  for (int motspeed = 0; motspeed <= 255; motspeed++)
  {
    analogWrite(ENA_PIN, motspeed); // control the speed
    Serial.println(motspeed);
      delay(10);
    }
    delay(1000); // rotate at maximum speed 1 seconds in in clockwise direction
    Serial.print("Change direction");
    delay(250);
    // change direction
    digitalWrite(IN1_PIN, LOW);   // control motor A spins anti-clockwise
    digitalWrite(IN2_PIN, HIGH);  // control motor A spins anti-clockwise
    delay(1000); // rotate at maximum speed 1 seconds in in anti-clockwise direction
    for (int motspeed = 255; motspeed >= 0; motspeed--)
  {
    analogWrite(ENA_PIN, motspeed); // control the speed
    Serial.println(motspeed);
    delay(10);
  }
  Serial.println("Stop motor");
  delay(1000); // stop motor 1 second
  Serial.println("Change direction");
  delay(250);
}

Open the IDE monitor at 9600.
Tom... :smiley: :+1: :coffee: :australia:
PS, Check the continuity of your jumper leads...