Serial Data keeps repeating in Serial Monitor

I'm using android app and arduino in our project. The android app will send a string of data to the arduino. The receive data will be displayed in the Serial monitor of the arduino IDE. The receiving process is okay since the arduino correctly receive the string of data. The only problem is the data receive keeps repeating in the arduino Serial monitor. I'm a beginner in arduino programning.

#include <SoftwareSerial.h>

SoftwareSerial btserial(10, 11); //RX, TX

int ledpin = 13;
String val;

void setup() {
  Serial.begin(19200);
  Serial.println("CLEARDATA");
  Serial.println("LABEL,Time,Name,Location");
  pinMode(ledpin, OUTPUT);
  btserial.begin(9600);
  digitalWrite(ledpin, LOW);
}

void loop() {
  if(btserial.available() > 0){
    char c = btserial.read();
    val += c;
}

  if (val.length() >= 13 ) {
      Serial.println("DATE,TIME,");
      Serial.println(val);
      Serial.println(",");
  }
      
  if (val == "faculty") {
      Serial.print("Faculty");
      Serial.flush();
      btserial.println("2nd floor 10 steps left");
      delay(250);
      btserial.println("10 steps left");
    
  }
  
  if (val == "conference") {
      Serial.println("Conference");
      btserial.println("2nd floor 5 steps right");
      delay(250);
      btserial.println("5 steps right");
 
  }
  
  if (val == "204") {
      Serial.println("204");
      btserial.println("2nd floor 10 steps right");
      delay(250);
      btserial.println("10 steps right");
  }
  
}

serial monitor.JPG

the data receive keeps repeating in the arduino Serial monitor

It will because that is how you wrote it.
If you want it to only print out when it gets data move that first } to the end of the loop function.

hi! I try moving the } in the end part of the loop function. The data stops repeating but it does not display it only once. Sometimes it displays twice, thrice but not only once.

In my code here, If the receive data length is greater than 13 characters, it will print in whatever the letters it compose. Is this correct?

if (val.length() >= 13 ) {
      Serial.println("DATE,TIME,");
      Serial.println(val);
      Serial.println(",");

Is this correct?

Yes.

I try moving the } in the end part of the loop function. The data stops repeating but it does not display it only once. Sometimes it displays twice, thrice but not only once.

You changed your code. It does not do what you want. Yet, you want us to guess what is wrong. No, thanks.

Okay,when the arduino receive the word "faculty", it displays the word "Faculty" in the serial monitor but when I send again the word "faculty", the receive data is more than 13 characters (facultyfaculty) in which the first IF statement is valid. I used serial.flush to erased the serial buffer but it doesn't work. What is the method in deleting the previous buffer data?

I used serial.flush to erased the serial buffer but it doesn't work.

That function blocks until the outgoing serial buffer is empty. It did exactly what it was supposed to do, so your definition or "work" is wrong.

What is the method in deleting the previous buffer data?

The proper method is to understand what available() and read() are doing. available() tells you how much data is in the buffer. read() removes one byte from the buffer. There is no function to delete the previous data because there is no previous data.

The problem is that after printing the value in the dreaded String, you are not deleting THAT data. It has NOTHING to do with the Serial buffer - incoming or outgoing.

thanks sir! I solved the repeating problem by puttint val="" at the end of the loop.