Using an interrupt instead of checking serial.available in loop

I'm implementing a project on the Arduino. The loop function drives two servo motors using data from analog pins.. and is quite long. I'm also reading data from Serial2, using a bluetooth module paired with an Android phone. Currently, the bluetooth is checked at the start of the loop, but the gap between Serial.available() calls is too long. Can I use an interrupt on the tx2/rx2 pins so the arduino knows to read data from the serial at any point during the loop.

void loop()
{
  char recvChar;

  if (blueToothSerial.available())
    { //check if there's any data sent from the remote bluetooth shield
      recvChar = blueToothSerial.parseInt();
      Serial.print(recvChar);

      if (recvChar % 2 == 0)
      {
        Serial.print("east/west:  ");
        Serial.println(east_west);
        Serial.print("north/south: ");
        Serial.println(north_south);
        Serial.print("rotations: ");
        Serial.println(rotations);

      }
     
      else {
        //do nothing
      }
    }
     //read data from analog pins
     //drive servo

}

the gap between Serial.available() calls is too long.

Please post your complete program so that we can see what is taking the time

parseInt() is the one causing delay in your code. It waits until it parses a whole int or it exceeds the timeout.

In the background the Arduino IDE already uses an interrupt to detect when a character arrives and move it to the Serial Input Buffer.

If you write non-blocking code that allows loop() to repeat frequently (hundreds of times per second) then there will be no problem getting data from the input buffer.

Have a look at the examples in Serial Input Basics - simple reliable non-blocking ways to receive data.

...R