Problem using stepper motor w/ l293

Hi! Can anyone help me?
I got a problem with my 24V stepper motor while using a L293 drive IC. I connected the L293 to a 24V source (it has a led indicator) for the motor voltage source while the for the IC's power source I simply connected it to the arduino directly. For the ground, I used 2 ground pins from the IC and connected it to the 24V and arduino ground.

During normal operation, the stepper motor would operate normally at first but will gradually slow down until it can no longer move.
I connected everything directly without any resistors, capacitors, etc. because i don't know what to add. Can anyone give me advise on this?

Here is my code for the arduino. My project involves 4 PIR sensors positioned 90 deg apart around the stepper motor in which the stepper motor will rotate to where motion is detected. However, I removed the PIR sensors in this setup and instead used the serial monitor wherein I will insert a 4 digit binary code which simulate the sensors output (North, East, South and West; ex. 0100 - motion detected at the east sensor).

  int in1Pin = 2;
  int in2Pin = 3;
  int in3Pin = 4;
  int in4Pin = 5;

  int ena = 7;
  
  int inp = 0;
  int inp1 = 0;
  int inp2 = 0;
  int inp3 = 0;
  int inp4 = 0;
  int inpt = 0;
  
  int pir1 = 0;
  int pir2 = 0;
  int pir3 = 0;
  int pir4 = 0;
  
  int pos = 0;
  int steps = 0;
  int current = 0;
  
  int p1 = LOW;
  int p2 = LOW;
  int p3 = LOW;
  int p4 = LOW;
  
  int cnts = 0;
  int rounds = 10000;
  
#include <Stepper.h>  
Stepper motor(48, in1Pin, in2Pin, in3Pin, in4Pin); 

void setup() {
  
  pinMode(in1Pin, OUTPUT);
  pinMode(in2Pin, OUTPUT);
  pinMode(in3Pin, OUTPUT);
  pinMode(in4Pin, OUTPUT);
  
  pinMode(ena, OUTPUT);
  
  motor.setSpeed(100);
  Serial.begin(9600);
}

void loop() {
  
   
  if (Serial.available())
  {
     digitalWrite(ena,HIGH);
    
     inp  = Serial.parseInt();
     inp1 = inp/1000;
     
     inpt = inp%1000;
     inp2 = inpt/100;
     
     pir1 = inpt%100;
     inp3 = pir1/10;
     
     inp4 = pir1%10;
     
        
  if (inp1 > 0)
  {
    p1 = HIGH;
  }
  else {} if (inp2 > 0)
  {
    p2 = HIGH;  
  }
  else {} if (inp3 > 0)
  {
    p3 = HIGH;  
  } 
  else {} if (inp4 > 0)
  {
    p4 = HIGH;  
  } 
  else {}
  
  
  ///ALL PIR'S ACTIVATED
  if (p1==HIGH && p2==HIGH && p3==HIGH && p4==HIGH)
  {     motor.step(48);    }
  else
  
  //3 PIR'S ACTIVATED
  if (p1==HIGH && p2==HIGH && p3==HIGH && p4==LOW)
  {    pos = 12;    }
  else if (p1==LOW && p2==HIGH && p3==HIGH && p4==HIGH)
  {    pos = 24;    }
  else if (p1==HIGH && p2==LOW && p3==HIGH && p4==HIGH)
  {    pos = 36;    }
  else if (p1==HIGH && p2==HIGH && p3==LOW && p4==HIGH)
  {    pos = 0;    }

  //2 PIR'S ACTIVATED
  else if (p1==HIGH && p2==HIGH && p3==LOW && p4==LOW)
  {    pos = 6;    }
  else if (p1==LOW && p2==HIGH && p3==HIGH && p4==LOW)
  {    pos = 18;    }
  else if (p1==LOW && p2==LOW && p3==HIGH && p4==HIGH)
  {    pos = 30;    }
  else if (p1==HIGH && p2==LOW && p3==LOW && p4==HIGH)
  {    pos = 42;    }
  
  //1 PIR ACTIVATED  
  else if (p1==HIGH && p2==LOW && p3==LOW && p4==LOW)
  {    pos = 0;     }
  else if (p1==LOW && p2==HIGH && p3==LOW && p4==LOW)
  {    pos = 12;    }
  else if (p1==LOW && p2==LOW && p3==HIGH && p4==LOW)
  {    pos = 24;    }
  else if (p1==LOW && p2==LOW && p3==LOW && p4==HIGH)
  {    pos = 36;    }
  else {}
  
  if (current>pos)
  {
  steps = -(current-pos);
  if ((-steps)>24)
  {
    steps = 48 + steps;
  }
  current = pos;
  }
  
  else if (current<pos)
  {
  steps = pos - current;
  if (steps>24)
  {
    steps = -(48 - steps);
  }
  current = pos;
  }
  else {}  
  
  motor.step(steps);  
  delay(500);
  
/*  Serial.print(cnt);
  Serial.print(",");  */
  Serial.print(inp1);
  Serial.print(",");
  Serial.print(inp2);
  Serial.print(",");
  Serial.print(inp3);
  Serial.print(",");
  Serial.println(inp4);
  Serial.print(p1);
  Serial.print(",");
  Serial.print(p2);
  Serial.print(",");
  Serial.print(p3);
  Serial.print(",");
  Serial.print(p4);
  Serial.print(",");
  Serial.print(pos);
  Serial.print(",");
  Serial.println(steps);
 
  pos=0;
  steps=0;
  p1= LOW;
  p2= LOW;
  p3= LOW;
  p4= LOW;
}
 else
 digitalWrite(ena,LOW);
}

I haven't studied your code but your symptoms are consistent with something that gradually saturates. Something in your code is probably no getting cleared when it should be.

If the motor runs OK at the start it's unlikely to be a problem related to the connections or logic to drive the motor, it's probably a fault in the logic that decides what the motor should do.

...R

Which motor? How much current does it take? Have you checked the supply and the driver aren't
overloading?