-1

I want to make some characters scroll left without affecting the first positions in each row of my LCD 16x2 screen. I have this code inside the loop so far:

lcd .clear();
lcd.setCursor(17, 0);
for (int i = 15; i > 0; i--) {
  lcd.print("x");
  lcd.scrollDisplayLeft();
  if (digitalRead(switchPin) == HIGH) {
    lcd.setCursor(0, 0);
    lcd.write(5);
  } else {
    lcd.setCursor(0, 1);
    lcd.write(5);
  };
  lcd.setCursor(17, 0);
  delay(500);
}
lcd.noAutoscroll();

I think it should work, but the character x just moves left by one position, whereas the character in the first position, either in the first or second row doesn't appear at all.

James Waldby - jwpat7
  • 8,920
  • 3
  • 21
  • 33
menislici
  • 117
  • 1

1 Answers1

0

I would do the following (beware - not tested):

lcd.clear();
lcd.setCursor(15, 0);
lcd.print("x");
for (int i = 0; i < 15; i++) {
    lcd.setCursor(0, digitalRead(switchPin) == LOW);
    lcd.print("5");
    delay(500);
    lcd.scrollDisplayLeft();
}
Igor Stoppa
  • 2,125
  • 1
  • 15
  • 20