Serial LCD display 6 char's expect 4 0000- 1023

This code reads the analog data being xmitted by an XBEE endpoint. That works well, I am having an issue with the sparkfun serial display. The code below outputs 6 characters I am expecting (or would like only 4) 0 to 1023.

Any helpful ideas. I'll use the XBEE lib after I get this working. :slight_smile:

Hardware xbee 1.0 end point and xbee 1.0 shield on an UNO

//xbee router
#include <SoftwareSerial.h>

;SoftwareSerial mySerial(10, 11); // RX, TX
// the setup routine runs once when you press reset:
 byte discardbyte;

int led = 13;
void setup() {
  // initialize serial communication at 9600 bits per second:
  pinMode(led, OUTPUT); 
  Serial.begin(9600);
   mySerial.begin(9600);
  mySerial.write(254);
  mySerial.write(01);
  mySerial.write(254);
  mySerial.write(129);
  mySerial.print("SEN1 SEN2 SEN3");
}

void loop() {
 
  if (Serial.available()>=23){
    
    if (Serial.read()==0x7E){
     
         for (int i=1; i<15; i++){
          discardbyte = Serial.read();
   
        } 
    }
       int analogLSB = Serial.read();
       int analogMSB = Serial.read();
 
int analogReading =  analogLSB + (analogMSB * 256);
     constrain(analogReading, 0, 1023);
 
      
       Serial.println(analogReading);

mySerial.write(254);
mySerial.write(193);

mySerial.print(analogReading, DEC);
//mySerial.write(254);
//mySerial.write(197);
//mySerial.write(" ");
//analogReading=0;
    }
 
}

Can you be a bit more precise - are you expecting 000 to 1023 (ie, always 4 characters) or are you expecting 0 (1 character) to 1023 (4 characters)?

mySerial.write(254);
mySerial.write(193);
mySerial.print(analogReading, DEC);

Total output is 1 + 1 + (1 up to 4) = 3 to 6 characters

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

;Why ;does ;this ;statement ;start ;with ;a ;semicolon? Statements END with semicolons.