How to display inputed words by Serial on LCD

Hi,

I couldn't show word on LCD keypad Shield wit Arduino UNO...
I can display 1 character only. I mean if I input "CAT", LCD just shows "C".
How can I word on LCD?

#include <LiquidCrystal.h>
byte byteRead;
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int lcd_count = 0;

void setup() {                
 Serial.begin(9600); 
 lcd.begin(16, 2);              
 lcd.setCursor(0,0);
 lcd.print("Your messages...");
}

void loop() {
  if (Serial.available()) {
    byteRead = Serial.read();
    Serial.write(byteRead);
    lcd.setCursor(0,1);
    lcd.write(byteRead);
  }
}

I can display 1 character only. I mean if I input "CAT", LCD just shows "C".

If you enter "CAT", the LCD should show "T" because you tell it to print each letter in the same position.

I have solved it by myself!!

#include <LiquidCrystal.h>
byte byteRead;
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int lcd_count = -1;
int lcd_clear = 15;

void setup() {                
 Serial.begin(9600); 
 lcd.begin(16, 2);              
 lcd.setCursor(0,0);
 lcd.print("Your messages...");
}

void loop() {
  if (Serial.available()) {
    
    byteRead = Serial.read();
    Serial.write(byteRead);
    lcd_count += 1;
    lcd.setCursor(lcd_count,1);
    lcd.write(byteRead);
    
//clear characters
    if(lcd_count > 15){
      int i;
      for(i=0;i<lcd_count;i++){
         lcd.setCursor(i,1);
         lcd.write(" ");
      }
        lcd_count = -2;
        lcd.setCursor(lcd_count,1);
        lcd.write(byteRead);
        lcd_count++;
     }
     //clear characters   

  }

}

Now, my code can receive Serial input from OSX and display it on LCD shield!

    lcd_count += 1;

How many LCDs do you have? Is it really necessary to count them?

PaulS:

    lcd_count += 1;

How many LCDs do you have? Is it really necessary to count them?

Paul,
Come on, you can look at the code and see what the counter is being used for.

Paul,
Come on, you can look at the code and see what the counter is being used for.

I know. But, will OP remember in 6 months when looking back at the code? Meaningful names help. What is being counted is characters, not LCDs. So, the name should be char_count.

So, the name should be char_count.

That could still be confusing as the variable is used to set the LCD column to be printed in.

That could still be confusing as the variable is used to set the LCD column to be printed in.

Then, call it columnCount. What is not being counted, though, is LCDs. Characters or columns are. There is a one to one correspondence, so I'd use whichever name felt more natural.

Agreed wholeheartedly.