my l298n pass away. stepper motor wiring problem or code

I just want to control stepper motor with Arduino mega and l289n.

this is what I did it.

this is the code what I use.

#include <Stepper.h>
 
const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
                                             // for your motor
 
                                             // initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);

void setup() {
                                            // set the speed at 60 rpm:
  myStepper.setSpeed(60);   
                                            // initialize the serial port:
  Serial.begin(9600);
}

void loop() {
  char read_data;
  int i;
 
  if(Serial.available())
  {
    read_data = Serial.read();
 
  
  if(read_data =='1')
  {
 
  Serial.println("clockwise rotation");
 
  for(i=0;i<400;i++)      //control motor angle
  {
    myStepper.step(1);    
    delay(10);            //control motor speed
  }
  }
 
  else if(read_data == '2')
  {
   
  Serial.println("counterclockwise rotation");
 
  for(i=0;i<400;i++)       //control motor angle
  {
    myStepper.step(-1);
    delay(10);             //control motor speed
  }
  }
  
 }
}

if you type 1 in serial monitor then turn clockwise rotation, and type 2 turn reverse.

actually I type 1 and 2 continuously then the l298n exploded!

when I typed 1,2, ... the motor operate as error robot. it looks like the motor try to rotate both clockwise and counterclockwise at the same time.

is it reason for burn?

and can I still use Arduino mega?

this is the motor data sheet

l298n datasheet


this is SMPS power supply


actually the wires make me confused. I thought that black and green are part of same coil. red and blue also do. did I misunderstood? did I wire it wrong? why green and red wire twisted.


after l298n passed away. I unplugged Arduino, turn off power supply.

Please use code tags when posting code.

then the l298n exploded!

Not surprising. The ancient, inefficient L298n is for tiny toy motors, not stepping motors.

For your particular motor, you need a stepper motor driver capable of at least 1.7 Amperes per phase. And you must follow instructions to set the current limit correctly.

Here is a suitable stepper driver. If your project does not require the full output torque of that motor, this one will work, but you must set the current limit to 1.5 Amperes.

DO NOT use breadboards for motor wiring. The tracks will burn from the high current. Solder the motor wires directly to the driver, or use screw terminals if provided.

jremington:
Please use code tags when posting code.

thank you for your advice!

jremington:
If your project does not require the full output torque of that motor

Actually, I require the full output torque of that motor!

How can I test the full output torque of this motor? can you advice for it?
And also how to set the current limit to 1.5 Amperes? by using resistance components and V I R calculating?

Actually, I require the full output torque of that motor!

Then you need this motor driver, or one capable of even higher current.

Follow the instructions for the motor driver to set the current limit.