简体   繁体   中英

Arduino LCD only display fisrt 16 characters on line 1 and 41 to 46 caracters in line 2

when I use <LiquidCrystal.h library and lcd-write() it only show the first 16 char in the fist row and start in the 41st char in the second row.

I started with lcd.begin(16,2) .

Here an example of the code. The result of this code will be: row 1: 0123456789112345

row 2: 4123456789

#include <LiquidCrystal.h>
LiquidCrystal lcd(2,3,4,5,6,7);
void setup() {
  // put your setup code here, to run once:
  lcd.begin(16, 2);
  Serial.begin(9600);
  lcd.print("0123456789");
  lcd.print("1123456789");
  lcd.print("2123456789");
  lcd.print("3123456789");
  lcd.print("4123456789");
}
void loop() {
}

Its that the expected functionality? There are a way so I can get the 17th char be displayed in second row.

I'm not completely sure why your Arduino has this behaviour but you can pass a complete line in your case 16 characters every time you print and look how it works, also parsing in variables ant passing it to the .print method.

Another way is to set manually the data in the row that you want using the setCursor() method, this method helps you to move and print in the position that you want, it receives two parameters the column and the row, I'll let you the URL with more information.

https://www.arduino.cc/en/Tutorial/LiquidCrystalSetCursor

Yes, that is the expected behaviour. The library allows you to control HD44780-based LCD modules. This LCD controller can drive displays up to 40 character by 2 lines in size. When you use a smaller module, the lines are still stored in the same locations in the DDRAM: the first line starts at location 0, the second line starts at location 40. See the datasheet for more information:

https://www.sparkfun.com/datasheets/LCD/HD44780.pdf

You can use the entire memory and scroll left and right since the 16-character wide display is a window into the DDRAM. You can use the scrollDisplayLeft and scrollDisplayRight to shift the display left and right. These functions change which DDRAM address is used for the first character on the far left of the display. Both lines scroll in unison.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM