how create loop in loop

I have a code for control a stepper motor, the objective is rotate the axix in 360 with delay of 500 and returned to begins, my problem is rotate in 360 , is possible create the loop in other loop, (the relays no control the motor )
this is my code

#include <AccelStepper.h>
//#include <loop>
// Define a stepper and the pins it will use
AccelStepper stepper(AccelStepper::DRIVER, 5, 2);
int main(void);
int pos = 50;
int teste;

//Porta ligada ao pino IN1 do modulo
int porta_rele1 = 7;
//Porta ligada ao pino IN2 do modulo
//int porta_rele2 = 8;

void setup()
{ 
 Serial.begin(9600);
 stepper.setEnablePin(8);
 stepper.setMaxSpeed(4000);
 stepper.setAcceleration(4000);
 //// adicionei aqui igual no script do rele
 pinMode(porta_rele1, OUTPUT);
 //stepper.setPinsInverted(false,false,true);

 //stepper.enableOutputs();
// Serial.begin(9600);

}

void loop ()
{
   
   
 Serial.println("");
 if(Serial.available()> 0)
 
 
teste = Serial.read () ; '-0';
 //// Comentei aqui
 if (teste == 116) 
   //for if (teste==116)(int graus = 0; graus <= 72; graus++){//// adicionei essas 4 linhas aqui igual no script do rele
   digitalWrite(porta_rele1, HIGH);  //Liga rele 1
 
      Serial.println(teste);

   digitalWrite(porta_rele1, LOW); //Desliga rele 1
 //  delay(3000);
   if (stepper.distanceToGo() == 0)
     {
       delay(500);
       pos = -pos;
       stepper.moveTo(pos);
     }
   stepper.run();
   
   
   }

code i have create execute delays of 500 continuous , my objective create a cicly of 360 with breaks of 500 and restart the cycle

Please edit your post to add code tags, as described in "How to use this forum".

The loop() function loops automatically. Please explain why you think you need another loop, and what that loop would do.