HI GUYS HELP ME HOW TO GET THE VALUE

HELP ME HOW TO GET THE VALUE printed on the serial monitor then save it into variable
picture attach. thanks in advance

/////////////////******************** DECLARATION OF DATA********************/////////
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////



byte Serial1Data;
byte crud;

String capture="";
boolean doCapture=false;
byte setCMD=0;

String jayson ="+INQ:BCF5:AC:6FBEF2,5A020C,7FFF";



/////////******************* PROGRAM STARTS HERE**************/////////////
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////



void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial1.begin(38400);
  delay(200);
  showMenu();
}
 
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
 

void loop() {
  if (Serial.available() > 0) {
    if (!doCapture) {
      crud=Serial.read();
    }
    else
    {
      char theVal=Serial.read();
      if (capture.length() == 0 && theVal == ',') {// skip the comma
        //Serial.println("got the comma");
      }
      else
      {
        capture.concat(theVal);
        if (theVal == '\n') {
          handleSetCMD(setCMD);// go do the function
        }
        

                
      }
    }
  }
  
  
  ////////////////******CASE STATEMENT FOR COMMANDS********************///////////
  ///////////////////////////////////////////////////////////////////////////////
  //////////////////////////////////////////////////////////////////////////////
  
  if (crud != 0) {
    switch (crud) {
    case 'm':
      showMenu();
      break;
    case '1':
      Serial1.write("AT\r\n");
      break;
    case '2':
      Serial1.print("AT+INIT\r\n");
      break;
    case '3':
      Serial1.print("AT+INQ\r\n"); 
      break;
    case '4':
      Serial1.print("AT+NAME?\r\n");
      break;
    case '5':
      Serial1.print("AT+ROLE?\r\n");
      break;
    case '6':
      Serial1.print("AT+UART?\r\n");
      break;
    case '7':
      Serial1.print("AT+STATE?\r\n");
      break;
    case '8':
      Serial1.print("AT+PSWD?\r\n");
      break;
    case '9':
      Serial1.print("AT+ORGL\r\n");
      break;
    case 'a':// set device name
      doCapture=true;
      crud=0;
      setCMD=1;
      break;
    case 'b':// set role
      doCapture=true;
      crud=0;
      setCMD=2;
      break;
    case 'c':// set password
      doCapture=true;
      crud=0;
      setCMD=3;
      break;
    case 'd':// set UART baudRate, Stop, Parity
      doCapture=true;
      crud=0;
      setCMD=4;
      break;
    }
  }
  if (Serial1.available()){
    Serial1Data=Serial1.read();
    Serial.write(Serial1Data);   
  }
  
  
  delay(100);// prepare for next data ...








/////////////////////////////////////*******CONDITION*********///////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////













/////////////////////EDIT BLUETOOTH SHIELD/////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////


}

void handleSetCMD(byte whichCMD) {
  switch (whichCMD) {
  case 1:// set the device name
    Serial1.print("AT+NAME="+ capture + "\r\n");
    break;
  case 2:// set the role
    Serial1.print("AT+ROLE="+ capture + "\r\n"); // 0,1,2 (slave, master, slave loop)
    break;
  case 3:// set the password (four digits; most computers using 0000)
    Serial1.print("AT+PSWD="+ capture + "\r\n");
    break;
  case 4:// set the UART (baud, stop, parity)
    Serial1.print("AT+UART="+ capture + "\r\n");
    break;
  }
  capture="";
  doCapture=false;
  crud=0;
  setCMD=0;
}
//////////////////////////////

void showMenu(){
  Serial.println(" ");
  Serial.println(F("1. AT test"));
  Serial.println(F("2. Initiate"));
  Serial.println(F("3. Inquire"));
  Serial.println(F("4. Name"));
  Serial.println(F("5. Role"));
  Serial.println(F("6. UART"));
  Serial.println(F("7. State"));
  Serial.println(F("8. Password"));
  Serial.println(F("9. Reset"));
  Serial.println(F("a. Set Device Name (a,name)"));
  Serial.println(F("b. Set Role (b,0)"));
  Serial.println(F("c. Set Password (c,1234)"));
  Serial.println(F("d. Set UART (d,Baud,Stop,Parity)"));
  Serial.println(F("m. Display menu"));   
  Serial.println(" ");
}

Are we supposed to be mind readers or are you going to give us some clues as to the program that you are running that outputs the data to the Serial monitor and what data you want in how many variables ?

You can't capture the data once it is shown by the Serial Monitor - other than by writing it down on a piece of paper.

You have to send the data to a PC program that is capable of saving it. Most of the terminal programs - such as puTTY have the ability to save received data to a file.

This demo shows how you can use a Python program to communicate between a PC and an Arduino.

...R

But you've already got it in jayson. That's how you Serial.printed it in the first place :-/

Maybe you can try something like

Serial.print (theVal); //This is where you print the variable value to the serial monitor
Serial.println; //This just goes to the next line. Use this if you want to be organized and see what you are getting back more clearly

I think that will work for getting the value on the serial monitor. I would just try to use serial monitor on puTTY.

I hope this helps,

RockyRicky

KenF:
But you've already got it in jayson. That's how you Serial.printed it in the first place :-/

Unless he printed it character by character as it was received and didn't save it.

When we see the program we will know.