C# and Arduino - Writting on LCD display full line char

Hi guys, im sorry for dropping in like this, im having a problem figuring out how to send a full line into LCD display, the current code i have only writes 1 char at once, actually i tried changing it to loop through every 16 position and write each letter, however it fades the previous letter and then writes the next, i wanted to display every word i typed for as long as the LCD can write it.

Here's my actual C# code: actual C# - Pastebin.com

and then there's the arduino code.

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);


void setup()
{
  lcd.begin(16, 2);
  Serial.begin(9600);  
}

void loop()
{
  if(Serial.available())        
  {
    char c; 
    c = Serial.read();
    for(int i = 0; i <1; i++){
    lcd.scrollDisplayRight();
    Serial.write(c);
    lcd.setCursor(i, 0);
    lcd.print(c);
    }
      delay(2000);
      }
         lcd.setCursor(0, 0);
         lcd.print("                                             ");
      }

Do you want the received text to scroll or just to be displayed as static text ?

just static

OK.

Clear the LCD line, set the cursor position to the beginning of the line and set a counter to zero
When a character becomes available then read it and print it to the LCD and increment the counter.
Keep reading from Serial when a character is available and writing to the LCD.
When the counter reaches 16 stop reading Serial and wait a while
Start the process again

Note that the C# program sending the data must not close the serial connection or the Arduino will be reset.

Im not sure i was able to understand what you mean lol. Here's what i tried

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);


void setup()
{
  lcd.begin(16, 2);
  Serial.begin(9600);  
}

void loop()
{
  if(Serial.available())        
  {
    char c; 
    int i;
    i = 0;
    while( i < 16){
    c = Serial.read();
    Serial.write(c);
    lcd.setCursor(i, 0);
    lcd.print(c);
    i++;
    }
    lcd.scrollDisplayRight();
    }
}

The current output plays out like this:

Can you please add that image as an attachment, per forum guidelines? Most people won't follow offsite links, especially when you don't bother to mark them with a URL tag.

aarg:
Can you please add that image as an attachment, per forum guidelines? Most people won't follow offsite links, especially when you don't bother to mark them with a URL tag.

Fixed, sorry.

You are reading 16 characters but you don't know if 16 are available

Try this (untested)

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
byte counter = 0;

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

void loop()
{
  if (Serial.available()) //only read when a character is available
  {
    lcd.print(Serial.read());
    counter++;
  }
  if (counter == 16)
  {
    delay(5000);
    lcd.setCursor(0, 0);
    lcd.print("                ");
    counter = 0;
    lcd.setCursor(0, 0);
  }
}

Awesome, exactly what i wanted. I just made some fixes since Serial.read() was sending text into bytes(numbers) to the lcd screen, all i did was store the reading into a char variable and works just as intended, thanks a lot!!!!!!!!!!!

here's the whole code

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int counter = 0;

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

void loop()
{
  if (Serial.available()) //only read when a character is available
  {
    char c = Serial.read();
    Serial.write(c);
    lcd.print(c);
    counter++;
  }
  if (counter == 16)
  {
    delay(5000);
    lcd.setCursor(0, 0);
    lcd.print("                ");
    counter = 0;
    lcd.setCursor(0, 0);
  }
}

// CREDITS TO UKHeliBob