16*2 lcd

I want to move character on 16*2 display but not like scroll or left to right I want to move character in both (x,y) plane.any coding solution

Not quite sure what you are wanting or the type interface you have to the LCD, but if you use the hd44780 library, you can read characters from the display.
You position the cursor to the desired position, read the character or multiple characters, then position to wherever you want and write the character(s).

--- bill

use this library function:

lcd.setCursor(0, 1);

related to lcd1602 library

goto File / examples / LiquidCrystal / setCursor

this example has the set cursor code example to set the cursor and move it to all the cells.

wolfrose:
use this library function:

lcd.setCursor(0, 1);

related to lcd1602 library

I'm assuming the OP wants to move a character that was already written on the display to a new location on the display.
setCursor() doesn't move a character. It merely sets the cursor position (location) for the next character to be written to the lcd.

bperrybap:
Not quite sure what you are wanting or the type interface you have to the LCD, but if you use the hd44780 library, you can read characters from the display.
You position the cursor to the desired position, read the character or multiple characters, then position to wherever you want and write the character(s).

--- bill

Shouldn't he also erase the character at the original position by replacing it with a ?

Don

floresta:
Shouldn't he also erase the character at the original position by replacing it with a ?

Don

Ah, yes, forgot about that...

https://retrolcd.com/Curriculum/Dinosaur

For the Dinosaur game, I render to a 32 character array and then print that to the screen one line at a time with a null terminator.

void RenderScreen() {
  int x, y;
  char line[17];
  byte point_char[16];

  String point_disp = "Pts:" + String(points);
  point_disp.getBytes(point_char, 16);

  for (x = 0; x < 16; x++) {
    PlotCHAR(x + 6, 0, (char)point_char[x]);
  }

  lcd.setCursor(0, 0);

  for (y = 0; y < screen_y; y++) {
    for (x = 0; x < screen_x; x++) {
      line[x] = Screen[x + y * screen_x];
    }
    line[16] = 0;
    lcd.setCursor(0, y);
    lcd.print(line);
  }
}

This could be simplified by using a 34 byte array with character 16 being a line break and character 33 being a null. You could then render the top line to 0-15, and the bottom line to 17-32

When you print the whole "screen" at once you avoid flicker.

Printing spaces is a "Dirty Rectangle" strategy.

bkucenski:
For the Dinosaur game, I render to a 32 character array and then print that to the screen one line at a time with a null terminator.


When you print the whole "screen" at once you avoid flicker.

Using a shadow buffer and then updating the display from that buffer is a common technique for handling display updates.
However, whole display/screen writes to these types of LCDs isn't what avoids flicker.
The main thing that creates flicker is clearing the LCD/screen using the clear display command then re-drawing the new stuff.
Overwriting what is on the screen typically doesn't cause flicker unless there are very frequent updates that are changing lots of the character positions that already contain something different on those positions.

--- bill

Fascinating how a random and unsubstantiated "hit and run" question can evoke such a detailed and off-topic discussion. :grinning:

Paul__B:
Fascinating how a random and unsubstantiated "hit and run" question can evoke such a detailed and off-topic discussion. :grinning:

While I have seen that in other threads, I did't seen that here.
It appeared that the OP asked how to move a character that was already on the display and wanted to move it in both a horizontal and vertical direction or to a new specific location.
He was offered two solutions:

  • use a library that supports reading the display to read it, write it somewhere else, and erase the orginal character.
  • use a shadow buffer to allowing moving the character in the shadow buffer and then re-write the whole display.

--- bill