Help troubleshooting DC motor

I am using Arduino Uno and a L298N motor controller to attempt to teach robotics. We have use the Uno to drive servos and continuous servos, so the next step is to try to control DC motors. I have a 12 volt battery wired through a fuse into the power side of the L298, and I have the pins on the Arduino connected as indicates in my code below to the L298. When we execute the code, the motors will not turn. Every 6 seconds or so, they will buzz, but not turn. We have swapped motors out, and we have swapped motor controllers. We can modulate the length of the buzz of the strength of the buzz by changing how long the delay is or the pwm value we send to the corresponding pins. But we can't turn the motors. Any advice?

void setup() { // put your setup code here, to run once:

define enB 9

define in1 4

define in2 5

define enA 8

define in3 6

define in4 7

pinMode (9, OUTPUT); pinMode (8, OUTPUT); pinMode (7, OUTPUT); pinMode (6, OUTPUT); pinMode (5, OUTPUT); pinMode (4, OUTPUT);

digitalWrite (4, LOW); digitalWrite (5, HIGH); digitalWrite (6, LOW); digitalWrite (7, HIGH); }

void loop() { delay (5000); // put your main code here, to run repeatedly:

analogWrite (8, 255); analogWrite (9, 255); delay (1000);

analogWrite (8, 0); analogWrite (9, 0); }

common gnd is important. pin 8 has no PWM

watch the PWM as it is omly possible on 3,5,6,9,10,11 the power to the L298 nust be higher as 9 Volts, and it also needs a 5 Volt, but that one you can take from the arduino.

Probably a power problem but with no details of the motors or battery it's not easy to tell. Maybe get a better 12V battery or smaller motors or motors that only need the limited current that an L298 can supply.

BTW pin 8 is not a PWM pin on a Uno so analogWrite() to it won't do anything useful. Try switching enA to pin 10. And since you have taken the trouble to define pin names why not use the names in the rest of the code!

Steve