Output is 8 output each time

hye there… im used ph sensor and arduino uno…
why my result is display at LCd and serial monitor is 8 ph value each time? like picture below…and the ph print that should appear is not appear at

and here is coding that i used…thanks…

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7,8,9,10,11,12);

#include <SoftwareSerial.h>                                                    //add the soft serial libray
#define rxpin 2                                                              //set the RX pin to pin 2
#define txpin 3                                                              //set the TX pin to pin 3


SoftwareSerial myserial(rxpin, txpin);                                         //enable the soft serial port


String inputstring = "";                                                       //a string to hold incoming data from the PC
String sensorstring = "";                                                      //a string to hold the data from the Atlas Scientific product
boolean input_stringcomplete = false;                                          //have we received all the data from the PC
boolean sensor_stringcomplete = false;                                         //have we received all the data from the Atlas Scientific product


  void setup(){                                                                //set up the hardware
     Serial.begin(38400);                                                      //set baud rate for the hardware serial port to 38400
     myserial.begin(38400);                                                    //set baud rate for software serial port to 38400
     inputstring.reserve(1);                                                   //set aside some bytes for receiving data from the PC
     sensorstring.reserve(1);      //set aside some bytes for receiving data from Atlas Scientific product
     lcd.begin(16, 2);
     lcd.println("Ph : ");
   }

/*

   void serialEvent() {                                                         //if the hardware serial port receives a char
               char inchar = (char)Serial.read();                               //get the char we just received
               inputstring += inchar;                                           //add it to the inputString
               if(inchar == '\r') {input_stringcomplete = true;}                //if the incoming character is a <CR>, set the flag
              }  

*/

void loop(){                                                                   //here we go....
     
  if (input_stringcomplete){                                                   //if a string from the PC has been recived in its entierty 
      myserial.print(inputstring);                                             //send that string to the Atlas Scientific product
      lcd.println(inputstring);                                                  //
      inputstring = "";                                                        //clear the string:
      input_stringcomplete = false;                                            //reset the flage used to tell if we have recived a completed string from the PC
      }


  while (myserial.available()) {                                               //while a char is holding in the serial buffer
         char inchar = (char)myserial.read();                                  //get the new char
         sensorstring += inchar;                                               //add it to the sensorString
         if (inchar == '\r') {sensor_stringcomplete = true;}                   //if the incoming character is a <CR>, set the flag
         }


   if (sensor_stringcomplete){                                                 //if a string from the Atlas Scientific product has been received in its entirety
       Serial.print(sensorstring);        //use the hardware serial port to send that data to the PC sensorstring = "";
      lcd.setCursor(0, 1);
      lcd.println(sensorstring);        //print the current status of the pH into the LCD                                                             //clear the string:
       sensorstring = ""; 
       sensor_stringcomplete = false;                                         //reset the flag 
      }
      delay(10000);   // Wait about 10 seconds to display 

      
}

below is my serial monitor output…

hidayah: below is my serial monitor output.....

The code looks fine. I would be curious to know what the input to the device is, and how the device handles it.

     inputstring.reserve(1);                                                   //set aside some bytes for receiving data from the PC
     sensorstring.reserve(1);      //set aside some bytes for receiving data from Atlas Scientific product

Why are you reserving one byte? If you really only expect one byte, why are you pissing away resources using a String?

the input is from ph sensor atlas scientific.... and the hardware that i used is arduino uno,lcd and GSM... to transfer the ph value to the phone owner..

before this i used 30 and 5 bytes.. but nothing happen, same like i put 1 byte like that.... that is effect to the value?

i dont know how to display the 1 value each time?? the output now is display 8time each.... :(

hidayah: the input is from ph sensor atlas scientific.... and the hardware that i used is arduino uno,lcd and GSM... to transfer the ph value to the phone owner..

OK, but WHAT is coming in, exactly? Place a Serial.printl(inchar) in the while (myserial.available()) { loop, and tell us what comes in to the Serial Monitor.

Additionally, what data being sent to the pH sensor is causing it to respond? You have serialEvent() commented out, and I don't see any other code that would send anything to the sensor.

before this i used 30 and 5 bytes.. but nothing happen, same like i put 1 byte like that.... that is effect to the value?

I have no idea what that means. what do you mean by "used 30 and 5 bytes", and by "same like i put 1 byte like that...."., and by "that is effect to the value?".

the ph sensor output is from string… i try throw this code… it not effect the value…

void serialEvent() {                                                         //if the hardware serial port receives a char
               char inchar = (char)Serial.read();                               //get the char we just received
               inputstring += inchar;                                           //add it to the inputString
               if(inchar == '\r') {input_stringcomplete = true;}                //if the incoming character is a <CR>, set the flag
              }

and the output is from this column…

   if (sensor_stringcomplete){                                                 //if a string from the Atlas Scientific product has been received in its entirety
       Serial.print(sensorstring);        //use the hardware serial port to send that data to the PC sensorstring = "";
      lcd.setCursor(0, 1);
      lcd.println(sensorstring);        //print the current status of the pH into the LCD                                                             //clear the string:
       sensorstring = ""; 
       sensor_stringcomplete = false;                                         //reset the flag 
      }

i try disable this code… lcd.println(sensorstring); the value is not come out… i dont know the exactly function…

this is the code before i edit…

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7,8,9,10,11,12);

#include <SoftwareSerial.h>                                                    //add the soft serial libray
#define rxpin 2                                                              //set the RX pin to pin 2
#define txpin 3                                                              //set the TX pin to pin 3


SoftwareSerial myserial(rxpin, txpin);                                         //enable the soft serial port


String inputstring = "";                                                       //a string to hold incoming data from the PC
String sensorstring = "";                                                      //a string to hold the data from the Atlas Scientific product
boolean input_stringcomplete = false;                                          //have we received all the data from the PC
boolean sensor_stringcomplete = false;                                         //have we received all the data from the Atlas Scientific product


  void setup(){                                                                //set up the hardware
     Serial.begin(38400);                                                      //set baud rate for the hardware serial port to 38400
     myserial.begin(38400);                                                    //set baud rate for software serial port to 38400
     inputstring.reserve(30);                                                   //set aside some bytes for receiving data from the PC
     sensorstring.reserve(5);      //set aside some bytes for receiving data from Atlas Scientific product
     lcd.begin(16, 2);
     lcd.println("Ph : ");
   }


   void serialEvent() {                                                         //if the hardware serial port receives a char
               char inchar = (char)Serial.read();                               //get the char we just received
               inputstring += inchar;                                           //add it to the inputString
               if(inchar == '\r') {input_stringcomplete = true;}                //if the incoming character is a <CR>, set the flag
              }  


void loop(){                                                                   //here we go....
     
  if (input_stringcomplete){                                                   //if a string from the PC has been recived in its entierty 
      myserial.print(inputstring);                                             //send that string to the Atlas Scientific product
      lcd.println(inputstring);                                                  //
      inputstring = "";                                                        //clear the string:
      input_stringcomplete = false;                                            //reset the flage used to tell if we have recived a completed string from the PC
      }


  while (myserial.available()) {                                               //while a char is holding in the serial buffer
         char inchar = (char)myserial.read();                                  //get the new char
         sensorstring += inchar;                                               //add it to the sensorString
         if (inchar == '\r') {sensor_stringcomplete = true;}                   //if the incoming character is a <CR>, set the flag
         }


   if (sensor_stringcomplete){                                                 //if a string from the Atlas Scientific product has been received in its entirety
       Serial.print(sensorstring);        //use the hardware serial port to send that data to the PC sensorstring = "";
      lcd.setCursor(0, 1);
      lcd.println(sensorstring);        //print the current status of the pH into the LCD                                                             //clear the string:
       sensorstring = ""; 
       sensor_stringcomplete = false;                                         //reset the flag 
      }
      delay(10000);   // Wait about 10 seconds to display 

      
}

http://www.gammon.com.au/serial

thanks nick... :)