Help with serial data on LCD

Hello. I have a simple project and need some help. I’m using fingerprint sensor with arduino and I have a driver board for finger print sensor that works with AT Commands. It works just fine but the problem is that I want to show received data from serial on LCD, and it shows like -1 !
the code that i use is as below:

#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 10, d5 = 9, d6 = 8, d7 = 7;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

SoftwareSerial FP(2, 3);

void setup() {

Serial.begin(9600);
FP.begin(9600);
lcd.begin(16,2);

}

void loop() {

if (FP.available()) {
Serial.write(FP.read());
}
if (Serial.available()) {
FP.write(Serial.read());
lcd.print(FP.read());
}

}

on serial monitor it just work fine and it is as it should be.
for example; when I type “AT” in serial monitor it gives “R30X” (name of FP module)
but on the LCD it give like “-1-1-1-1”
please help…

Don't you want to store what you read?
Does you LCD "hello world" sketch work as expected?
(Hint: what does serial read return when there is nothing to read?)

hello world sketch just work fine
and I'm sure LCD is ok

the 2 line IF codes are for writing at commands and communicating with serial and I used it as the example of Software serial

Did you understand my hint?

void loop() {
  if (FP.available()) {
    Serial.write(FP.read());
  }
  if (Serial.available()) {
    FP.write(Serial.read());
    lcd.print(FP.read());
  }
}

If the fingerprint device has any data, read and and send it to the Serial Monitor application.

If the Serial Monitor sent anything, send the first byte to the fingerprint reader, and then read something from the fingerprint reader, even though it hasn't sent anything, and show that on the LCD.

Seems to me that if you put every { on a line BY ITSELF, and properly formatted your code, it would have been perfectly obvious where to put the lcd.print() statement.

It also seems obvious that you can't read one character and send it to the Serial Monitor, and then read another character and send it to the LCD, and expect either output stream to be meaningful.

not exactly awol :frowning:
I'm not a pro like you!!

sajjad3245:
not exactly awol :frowning:
I'm not a pro like you!!

Suppose that you have a deck of cards. You draw a card, show it to your friend Joe, and then burn it. How are you then going to show that same card to your friend Bob?

void loop()
{
   if(Serial.available() > 0)
   {
      char c = Serial.read(); // Draw a card
      FP.write(c); // Show the card to Joe
      lcd.print(c); // Show the card to Bob
   }