Arduino: DC-Motor stockt?

Hallo,

ich bin gerade dabei, ein Roboterauto mithilfe von 4 DC-Motoren und einem Arduino Nano zu bauen. Ich habe zunächst alle Motoren direkt an das Batteriefach (4 x 1,5V) angeschlossen, um sicherzugehen, dass alle funktionieren. Jetzt habe ich einen an meinen Motor-Controller (L298N) angeschlossen, aber der Motor stockt jetzt und geht immer nur ein kleines Stück weiter, obwohl er eigentlich 3 Sekunden am Stück laufen und dann für 2 Sekunden stillstehen sollte (Siehe Code). Während der Motor läuft, sollte eine rote LED auf dem Arduino leuchten. Wenn ich den Motor ihn ohne Motor-Controller und Arduino teste, funktioniert er. Sobald ich ihn mit Controller und Arduino verbinde, stockt er und auch die rote LED blinkt nur kurz auf. Könnte es sein, dass mit dem Motor-Controller etwas nicht stimmt? Wo könnte das Problem sonst liegen?

Vielen Dank!

//This code is to use with L298n Dual H-bridge motor driver
//It just turns on a DC motor for a certain time and turn it off
//refer to surtrtech.blogspot.com for more information
int in1 = 9; //Declaring the pins where in1 in2 from the driver are wired 
int in2 = 8; //here they are wired with D9 and D8 from Arduino
void setup() {
  pinMode(in1, OUTPUT); //Declaring the pin modes, obviously they're outputs
  pinMode(in2, OUTPUT);
  pinMode(LED_BUILTIN, OUTPUT);
}
//Before starting the loop you should create functions type "void" to control the driver's pins
//Here I created two functions, the first one turns a motor to a direction (you can change it by switching LOW and HIGH
//and the second one to stop the motor
void TurnMotorA(){              
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);
  digitalWrite(LED_BUILTIN, HIGH);
}
void TurnOFFA(){
  digitalWrite(in1, LOW);
  digitalWrite(in2, LOW);
  digitalWrite(LED_BUILTIN, LOW);
}
void loop() {
  TurnMotorA(); //in the loop we use the function to turn the motor for 3s and stop it for 2s
  delay(3000);
  //delay(30000);
  
  TurnOFFA();
  delay(2000);
  //delay(20000);
}


Programm, Hardware, Computer, PC, Programmieren, Programmierung, Programmiersprache