Extracting serial data and display to 5digit 7segment

Hi Guys,

I have generally solved the problem in my led driver circuit now my problem is with the program. The equipment send the data for example " 00.." every one second. This is received by my rs232 to TTL converter and then go to my arduino uno. My problem is that the display is not constant. What I mean when the equipment sends " 12345". The 7 segment display will be "1" then disappear then after a second display "2" then disappear then after a second displays "3" then disppears then after a second displays "4" and then disappears then "5". The display should simultaneously display the 12345 instead of one by one. Please help me check my code.

#include <SoftwareSerial.h>

SevSeg sevseg;        // Initialize the SevSeg object
SoftwareSerial mySerial(A0, A1);
String receivedData = "";   // String to store the received data
long numberValue = 0;       // Variable to store the extracted number as a long

void setup() {
  mySerial.begin(9600);       // Initialize Serial communication
  byte hardwareConfig = N_TRANSISTORS;
  byte numDigits = 5;
  byte digitPins[] = {9, 10, 11, 12, 13};
  byte segmentPins[] = {8, 7, 6, 5, 4, 3, 2};
  bool resistorsOnSegments = true;
  bool updateWithDelaysIn = false;
  bool disableDecPoint = true;
  sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments, updateWithDelaysIn, disableDecPoint);
  sevseg.setBrightness(10);
  //byte numDigits = 5;       // Set the number of digits in your 7-segment display
  //byte digitPins[] = {2, 3, 4, 5, 6};  // Specify the digital pins connected to the display digits (A, B, C, D, E)
  //byte segmentPins[] = {7, 8, 9, 10, 11, 12, 13};  // Specify the digital pins connected to the display segments (a, b, c, d, e, f, g)

  // The following settings can be adjusted as needed
  //bool resistorsOnSegments = false;  // Set to 'true' if resistors are on the segment pins, otherwise 'false'
  //bool updateWithDelays = false;     // Set to 'true' to enable update with delays, otherwise 'false'
  //bool leadingZeros = true;         // Set to 'true' to enable leading zeros, otherwise 'false'
  //bool disableDecPoint = true;      // Set to 'true' to disable the decimal point, otherwise 'false'

  //sevseg.begin(COMMON_CATHODE, numDigits, digitPins, segmentPins, resistorsOnSegments,
  //             updateWithDelays, leadingZeros, disableDecPoint);
  //sevseg.setBrightness(90);   // Set the brightness of the display (adjust as needed)
}

void loop() {
  if (mySerial.available()) {
    char receivedChar = mySerial.read();    // Read a character from the Serial port

    // Check if the received character is a valid numerical value ('0'-'9') or a space
    if ((receivedChar >= '0' && receivedChar <= '9') || receivedChar == ' ') {
      // Skip leading spaces
      if (receivedData.length() > 0 || receivedChar != ' ') {
        receivedData += receivedChar;   // Add the character to the received data String
      }
    }
    // If the received character is a newline '\n', then convert the received data String
    // to a long integer and display it on the 7-segment display
    else if (receivedChar == '\n' && receivedData.length() > 0) {
      numberValue = extractNumberFromData(receivedData); // Convert String to long integer
      displayNumberOn7Segment(numberValue); // Display the extracted number on the 7-segment display
      receivedData = "";                 // Clear the receivedData String for the next number
    }
  }
}

// Function to extract the number from the String and convert it to a long integer
long extractNumberFromData(String data) {
  long extractedNumber = 0;
  bool isNegative = false;
  int startIndex = 0;

  // Check if the first character is a minus sign '-'
  if (data.charAt(0) == '-') {
    isNegative = true;
    startIndex = 1; // Start extracting the number from the second character
  }

  // Convert the numeric characters into a long integer
  for (int i = startIndex; i < data.length(); i++) {
    if (data.charAt(i) >= '0' && data.charAt(i) <= '9') {
      extractedNumber = extractedNumber * 10 + (data.charAt(i) - '0');
    }
  }

  // Apply the negative sign if applicable
  if (isNegative) {
    extractedNumber *= -1;
  }

  return extractedNumber;
}

// Function to display the number on the 7-segment display
void displayNumberOn7Segment(long number) {
  sevseg.setNumber(number);   // Display the extracted number on the 7-segment display
  sevseg.refreshDisplay();    // Refresh the display to show the number
  }