I am trying to read from bluetooth and write the data to an array

Hello everyone,
First of all i need to apologize for my english. It's not my native language.

So i have a problem with reading data from bluetooth module. When I start the program it goes before I write anything from my phone.

Here is my code:

#include <LiquidCrystal.h>
#include <Stepper.h>
#include <DS3231.h>
#include <SoftwareSerial.h>
#include <stdlib.h>
#include <string.h>

DS3231  rtc(SDA, SCL);
LiquidCrystal lcd(12, 11, 6, 5, 4, 3);
const int stepsPerRevolution = 512;  // change this to fit the number of steps per revolution

Stepper myStepper(stepsPerRevolution, 8, 10, 9, 13);

SoftwareSerial bt_iletisim(A2,A3);

const byte numChars = 32;
char receivedChars[numChars];   // an array to store the received data

boolean newData = false;

const int butonSayac = 2;
const int butonEnter = 7;

int piezoPin = A1;

int saat = 0;
int dakika = 0;
/*int butonDurumuSayac = 0;
int butonDurumuSayacDakika = 0;
int butonDurumuSayacIlac = 0;
int butonDurumuSayacGunde = 0;
int butonEnterDurum = 0;
int butonEnterDurumDakika = 0;
int butonEnterDurumIlac = 0;
int butonEnterDurumGunde = 0;*/
int saatTemp;
int dakikaTemp;
int ilacNoTemp;
int ilacTemp;
int ilacGunde = 0;
int ilacNumber = 1;
int kutuBaslangic = 1;
int kutuSecilen;
int kutuAnlik;
int i;
int kutuArray[7][4];
int ilacZamanArray[7][9];

String x;
int a,b,c;


void setup(){
  pinMode(butonSayac, INPUT);
  pinMode(butonEnter, INPUT);
  Serial.begin(9600);
  Serial.println("<Arduino is ready>");
  bt_iletisim.begin(9600);
  rtc.begin();
  lcd.begin(16,2);
  myStepper.setSpeed(60);
  
  // The following lines can be uncommented to set the date and time
  rtc.setDOW(TUESDAY);     // Set Day-of-Week to SUNDAY
  rtc.setTime(12, 18, 00);     // Set the time to 12:00:00 (24hr format)
  rtc.setDate(10, 1, 2019);   // Set the date to January 1st, 2014

  readFromBluetooth();
  
  delay(1000);
}
void loop(){
  long nowTime = millis();
  saatGuncel();
  alarmCheck();
//  recvWithEndMarker();
//  showNewData();

}

void alarmSet(){
  for(int k=0; k<7; k++){
    if(kutuArray[k][2]>0){
      for(int v=0; v<kutuArray[k][2]; v++){
        ilacZamanArray[k][v] = kutuArray[k][0] + v*(24/kutuArray[k][2]);
        if(ilacZamanArray[k][v]>23){
          ilacZamanArray[k][v]-=24;      
        }
      }
    }else{
      for(int d=0; d<8; d++){
        ilacZamanArray[k][d]= -1;
      }
    }
    ilacZamanArray[k][8] = (k+1);
  }
}

void alarmCheck(){
  for(int j=0; j<7; j++){
    for(int z=0; z<8; z++){
      //for(int y=0; y<ilacZamanArray[j][z]; y++){
        if(ilacZamanArray[j][z]==a && kutuArray[j][1]==b && c==0){
          tone(piezoPin,1000,500);
          motor(j+1);
        }
      //}
    }
  }
}


int motor(int m){ //for stepper
  kutuSecilen = m;
  kutuAnlik = kutuSecilen - kutuBaslangic;
  if(kutuAnlik<0){
    kutuAnlik = kutuAnlik + 7;
  }
  for(int l=0; l<kutuAnlik; l++){
    for(int r=0; r<292; r++){
      myStepper.step(1);
    }
  }
  kutuBaslangic = kutuAnlik;
}

void saatGuncel(){ //for time
  lcd.clear();
  lcd.print("Date: ");
  lcd.print(rtc.getDateStr());
  lcd.setCursor(0,1);
  lcd.print("Time:  ");
  x = rtc.getTimeStr();
  a=rtc.getSaat();    //Get current hour
  b=rtc.getDakika();  //Get current minute
  c=rtc.getSaniye();  //Get current second
  lcd.print(x);
  //lcd.print(b);
  lcd.setCursor(15,1);
  lcd.print(" ");
  
  // Wait one second before repeating :)
  delay (1000);

}
void readFromBluetooth(){

  for(i=0;i<7;i++){
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print(i+1);
  lcd.print(".kutu: ");
  lcd.setCursor(0,1);
  lcd.print("Saat: ");
  lcd.print(saat);
  delay(1000);
  recvWithEndMarker();
  
  saat = showNewData();
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print(i+1);
      lcd.print(".kutu: ");
      lcd.setCursor(0,1);
      lcd.print("Saat: ");
      lcd.print(saat);
      
  delay(1000);    
  saatTemp = saat;
    
  kutuArray[i][0] = saatTemp;   
  
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Dakika: ");
  lcd.print(dakika);
delay(10);
recvWithEndMarker();

dakika = showNewData();
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("Dakika: ");
      lcd.print(dakika);
delay(100);
  dakikaTemp = dakika;
    
  kutuArray[i][1] = dakikaTemp;  
    lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Gunde kac adet:");
  lcd.print(ilacGunde);
    delay(10);
recvWithEndMarker();
  ilacGunde=showNewData();
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("Gunde kac adet:");
      lcd.print(ilacGunde);
delay(100);
  ilacTemp = ilacGunde;
    
  kutuArray[i][2] = ilacTemp;
  kutuArray[i][3] = i+1;
  }
}

void recvWithEndMarker() {
    static byte ndx = 0;
    char endMarker = ',';
    char rc;
    
    while (bt_iletisim.available() > 0 && newData == false) {
        rc = bt_iletisim.read();

        if (rc != endMarker) {
            receivedChars[ndx] = rc;
            ndx++;
            if (ndx >= numChars) {
                ndx = numChars - 1;
            }
        }
        else if(rc == endMarker) {
            receivedChars[ndx] = '\0'; // terminate the string
            ndx = 0;
            newData = true;
        }
    }
}

int showNewData() {
    if (newData == true && strlen(receivedChars)>0) {
        
        int ba = atoi(receivedChars);
        Serial.println(ba);
        newData = false;

return ba;

    }
}

You are not using recvWithEndMarker() correctly, You should only call it in one place in loop(). If you call it in several places as you are doing there is no guarantee that there will be any data available or that the appropriate data will be available when you think it will be.

If you want to send three items of data and not get them mixed up then send them all in a single message like this (which is for 2 items)

Serial.print('<'); // start marker
Serial.print(value1);
Serial.print(','); // comma separator
Serial.print(value2);
Serial.println('>'); // end marker

It is also intended for use with recvWithStartEndMarkers() which will be more reliable, however you could leave out the markers if it was necessary.

Separately,

String x;

It is not a good idea to use the String (capital S) class on an Arduino as it can cause memory corruption in the small memory on an Arduino. This can happen after the program has been running perfectly for some time. Just use cstrings - char arrays terminated with '\0' (NULL).

And finally (for now) don't use single character variable names except as the iterator in a FOR loop as it is almost impossible to identify all the instances of a variable with a single character variable name. And in a few weeks time even you will be scratching your head wondering what the variable does. Always use meaningful variable and function names.

...R