Go Down

Topic: how to make 2 rows in Serial Display? (Read 727 times) previous topic - next topic

DMond

Hello guys! got a new LCD module. i am using the liquid display sketch from the arduino. However i cannot get more than 16 digits in a row. what i want is for the text to go to the second row.

Code: [Select]
// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup(){
    // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // initialize the serial communications:
  Serial.begin(9600);
}

void loop()
{
  // when characters arrive over the serial port...
  if (Serial.available()) {
    // wait a bit for the entire message to arrive
    delay(100);
    // clear the screen
    lcd.clear();
    // read all the available characters
    while (Serial.available() > 0) {
      // display each character to the LCD
      lcd.write(Serial.read());
    }
  }
}


anyone knows how to make the excess text to the second row? thanks!

semicolo

You should count the characters and when you reach 16 jump to the second line


Code: [Select]

void loop()
{
  // when characters arrive over the serial port...
  if (Serial.available()) {
    // wait a bit for the entire message to arrive
    delay(100);
    // clear the screen
    lcd.clear();
    int nbchars=0;
    // read all the available characters
    while (Serial.available() && i<16) {
      // display each character to the LCD
      lcd.write(Serial.read());
      nbchars++;
    }
    lcd.setCursor(0, 1);
    while (Serial.available()) {
      // display remaining characters on the second line
      lcd.write(Serial.read());
    }
  }
}

DMond

hey thanks for the reply, will work on it with your help =) happy easter!

Nick_Pyner


Hello guys! got a new LCD module. i am using the liquid display sketch from the arduino. However i cannot get more than 16 digits in a row. what i want is for the text to go to the second row.




anyone knows how to make the excess text to the second row? thanks!


I think yopu are looking for the cursor commands.  In the code below, a reading is put at the start of the first row (0) and then chr 11, then the same at start and chr 11 on the second row.

Code: [Select]
lcd.setCursor (0,0);
  lcd.print(InTemp);
  lcd.setCursor (11,0);
  lcd.print (OutTemp);
  lcd.setCursor(0,1);
  lcd.print(diff);
  lcd.print(" ");
  lcd.setCursor(11,1);
  lcd.print(DrainTemp);

DMond

hello, do i add the command in void loop? because it cant compile

Nick_Pyner

Yes. It is just a snippet and certainly won't compile by itself. It was just intended to show how the cursor command works but, if you put your own variables in, it should give you a display.

Go Up