volume motor controlled bu IR remote

So i have a IRreceiver, a DC motor and a L298N H-bridge module connected to an Arduino Nano. The circuit works well and all, but i need to have a smooth rotation when i keep the volume +/- button on the remote. I can’t seem to find a solution.
Using the code below, the motor works with a delay of 30 milliseconds, but because of that, it does not have a smooth rotation, rather a rapid on/off.
The motor is a potentiometer with reduction ratio motor. so i don’t need lower speed.

#include <IRremote.h>

//pin receptor IR
const int RECV_PIN = 6;
//Pinii pt driver motor
const int enA = 9;
const int in1 = 10;
const int in2 = 11;
//pin buton comutare sursa audio
const int button = 7;
//pini sursa audio
const int out1 = 2;
const int out2 = 3;
const int out3 = 4;
//pin activare tranzistor
const int tranzistor = 8;
//variabile
int output;
int contor = 0;

int buttonState = LOW;
long lastDebounceTime = 0;
long debounceDelay = 50;

unsigned long lastCode;

IRrecv irrecv(RECV_PIN);
decode_results results;

void setup() {
  Serial.begin(9600);
  pinMode(enA, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(button, INPUT);
  pinMode(out1, OUTPUT);
  pinMode(out2, OUTPUT);
  pinMode(out3, OUTPUT);
  pinMode(tranzistor, OUTPUT);
  //activam IR receiver
  irrecv.enableIRIn();

  //activare tranzistor si intarziere 12 sec
  //delay(15000);
  digitalWrite(tranzistor, HIGH);
  
  //activam output 1 cu intarziere 1 sec
  //delay(1000);
  digitalWrite(out1, HIGH);
  output = 1;

  //analogWrite(enA, 255);
  
}

void loop() {
  if(irrecv.decode(&results))  // verifica receptionare cod
  {
    Serial.println(results.value, HEX);
    if(results.value == 0xFFFFFFFF)
    {
      // daca se repeta, folosim ultimul cod primit
      results.value = lastCode;
    }

    if(results.value == 0xFFE01F) // buton volum -
    {
      lastCode = results.value;
      digitalWrite(in1, LOW);
      digitalWrite(in2, HIGH);
      contor = 1;
      //delay(1);
      //digitalWrite(in2, LOW);          
    }
    

    if(results.value == 0xFFA857) //buton volum +
    {
      lastCode = results.value;
      digitalWrite(in1, HIGH);
      digitalWrite(in2, LOW);
      contor = 1;
      //delay(1);
      //digitalWrite(in1, LOW);
    }

    if(results.value == 0xFF42BD) // button sursa
      {
        if(output == 1){
        digitalWrite(out1, LOW);
        delay(20);
        digitalWrite(out2, HIGH);
        output = 2;
        delay(50);
        results.value = 0;
      }
     }
    if(results.value == 0xFF42BD) // button sursa
      {
        if(output == 2){
        digitalWrite(out2, LOW);
        delay(20);
        digitalWrite(out3, HIGH);
        output = 3;
        delay(500);
        results.value = 0;
        }
      }
    if(results.value == 0xFF42BD) // button sursa
    {
      if(output == 3){
        digitalWrite(out3, LOW);
        delay(20);
        digitalWrite(out1, HIGH);
        output = 1;
        delay(500);
        results.value = 0;
      }
    }

    delay(30);
    irrecv.resume();
  }
  else
  {
    if (contor == 1)
    {
      Serial.println("intrerupe");
      digitalWrite(in1, LOW);
      digitalWrite(in2, LOW);
      contor = 0;
    }
  }

  if(digitalRead(button) == LOW){
    if(output == 1){
      digitalWrite(out1, LOW);
      digitalWrite(out2, HIGH);
      output = 2;
      delay(1000);
    }
  }

  if(digitalRead(button) == LOW){
    if(output == 2){
      digitalWrite(out2, LOW);
      digitalWrite(out3, HIGH);
      output = 3;
      delay(1000);
    }
  }

  if(digitalRead(button) == LOW){
    Serial.println("error");
    if(output == 3){
      digitalWrite(out3, LOW);
      digitalWrite(out1, HIGH);
      output = 1;
      delay(1000);
    }
  }


/*  buttonState=digitalRead(button);
  if((millis() - lastDebounceTime) > debounceDelay){
    if((buttonState == LOW) && output == 1){
      digitalWrite(out1, LOW);
      delay(50);
      digitalWrite(out2, HIGH);
      output = 2;
      lastDebounceTime=millis();
    }
    if((buttonState == LOW) && output == 2){
      digitalWrite(out2, LOW);
      delay(50);
      digitalWrite(out3, HIGH);
      output = 3;
      lastDebounceTime=millis();
    }
    if((buttonState == LOW) && output == 3){
      digitalWrite(out3, LOW);
      delay(50);
      digitalWrite(out1, HIGH);
      output = 1;
      lastDebounceTime=millis();
    }
   
  }
*/ 
}

How many milliseconds between the button code and the repeat code? How many milliseconds between each repeat code?

Store the time each time a button code arrives and wait until the expected repeat time expires before turning off the motor.

dumb question, how can i found the time between two IR signals?

Use the millis() or micros() function.

When the first signal arrives, record, in a variable*, the value of millis() (or micros()). When the secnod signal arrives record that time in a different variable. Subtract the first from the second to get the time elapsed between the two signals.

*Variables that deal with times, using the millis() or micros() functions, should be declared unsigned long.

So simple, yet never went through my mind. thank you, i'l keep you posted if i managed to solve it