LCD display 16*2

Zigzag function – the text comes letter by letter from the right side of the screen to the left side of the screen. Each character is taken starting with the first character of the text will shift from position 15.1 of the LCD screen to position 14.0 -> 13.1 -> 12.0 -> … -> 0.0. After the first character is positioned at 0.0, the second character starts to shift from position 15.0 -> 14.1 -> 13.0 -> 12.1 -> … ->.

So far i came up with this code but it's not correct,because i need to shift the String letter by letter, from position 15.1 of the LCD screen to position 14.0 -> 13.1 -> 12.0 -> … -> 0.0 and stops at the position 0.0,then the second letter starts from 15.0 -> 14.1 -> 13.0 -> 12.1 -> … -> and stops at 1.0,and so on

#include <LiquidCrystal.h>

LiquidCrystal lcd_1(12, 11, 5, 4, 3, 2);

String text = "Proiect 8";

void setup()
{
  lcd_1.begin(16, 2);//numarul de coloane si linii
  lcd_1.setCursor(0,0);//setam cursorul la coloana 1 si linia 0
}

void loop()
{
  
  
  zigzac(text);
  
}

void zigzac(String text) {
 int row = 0;
    for (int i = 15; i >= 0; i--) {
      lcd_1.setCursor(i, row);
      lcd_1.print(text);
      delay(50);
      lcd_1.setCursor(i, row);
      lcd_1.print(" ");
      lcd_1.clear();
      if (row == 0) {
        row = 1;
      } else {
        row = 0;
      }
    }
  

}



Can you give an example of how you want it to look (mock up the screen at each stage) versus what your code is currently doing?

Please do not duplicate posts on the same subject,
It's against forum rules and you could be punished for it.

" Slide text LCD 16*2 - #7 by exegete

#include <LiquidCrystal.h>
LiquidCrystal lcd_1(12, 11, 5, 4, 3, 2);
String text = "Proiect 8";

void setup() {
  lcd_1.begin(16, 2);//numarul de coloane si linii
  lcd_1.setCursor(0, 0); //setam cursorul la coloana 1 si linia 0
  zigzac(text);
}

void loop() {
  // this space intentionally left blank
}

void zigzac(String text) {
  int row = 0;
  for (int j = 0; j < sizeof(text); j++ ) { // loop for as many letters in "text"
    for (int i = 15; i >= 0; i--) {
      lcd_1.setCursor(i, row);
      lcd_1.print(text[j]); // one letter at a time at position [j]
      delay(100);
      lcd_1.setCursor(i, row);
      lcd_1.print(" ");
      lcd_1.clear();
      if (row == 0) {
        row = 1;
      } else {
        row = 0;
      }
    }
  }
  delay(300);
}

Same school...?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.