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;
}
}
}
#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);
}