Skip to main content
added 14 characters in body; edited title
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237

Arduino: Vertical "moving" text on a LCD-display

Following idea:

Following idea:

You have a LCD-display with 2 rows.

enter image description here

  1. You write the first line of a "text" to the second row. Then you clean the screen.

  2. After a delay you write the first line to the first row and a the second line of the text to the second row. Then follows another clean and delay.

  3. Then you write the second line to the first row and the third line to the second row. And so on ...

When the end of the text is reached the whole process starts again from the beginning.

That way the impression of an "vertical moving" text is accomplished.

YouThe code I have a LCD-display with 2 rows.

enter image description here

  1. You write the first line of a "text" to the second row. Then you clean the screen.

  2. After a delay you write the first line to the first row and a the second line of the text to the second row. Then follows another clean and delay.

  3. Then you write the second line to the first row and the third line to the second row. And so on ...

When the end of the text is reached the whole process starts again from the beginning.

That way the impression of an "vertical moving" text is accomplished.

The code I have written:written:

WorksIt works fine and by using an additional function I could avoid code-redundancies redundancies mostly.

But anyway: If someone has an idea how to improve my code or even doing it completely different in a better way, then I would appreciate his/her comment or answer. If someone has an idea how to improve my code or even doing it completely different in a better way, then I would appreciate his/her comment or answer.

Arduino: Vertical "moving" text on a LCD-display

Following idea:

You have a LCD-display with 2 rows.

enter image description here

  1. You write the first line of a "text" to the second row. Then you clean the screen.

  2. After a delay you write the first line to the first row and a the second line of the text to the second row. Then follows another clean and delay.

  3. Then you write the second line to the first row and the third line to the second row. And so on ...

When the end of the text is reached the whole process starts again from the beginning.

That way the impression of an "vertical moving" text is accomplished.

The code I have written:

Works fine and by using an additional function I could avoid code-redundancies mostly.

But anyway: If someone has an idea how to improve my code or even doing it completely different in a better way, then I would appreciate his/her comment or answer.

Vertical "moving" text on a LCD-display

Following idea:

You have a LCD-display with 2 rows.

enter image description here

  1. You write the first line of a "text" to the second row. Then you clean the screen.

  2. After a delay you write the first line to the first row and a the second line of the text to the second row. Then follows another clean and delay.

  3. Then you write the second line to the first row and the third line to the second row. And so on ...

When the end of the text is reached the whole process starts again from the beginning.

That way the impression of an "vertical moving" text is accomplished.

The code I have written:

It works fine and by using an additional function I could avoid code redundancies mostly. If someone has an idea how to improve my code or even doing it completely different in a better way, then I would appreciate his/her comment or answer.

Tweeted twitter.com/StackCodeReview/status/1041658086707093504
deleted 9 characters in body
Source Link
michael.zech
  • 4.5k
  • 8
  • 33
  • 56

Following idea:

You have a LCD-display with 2 rows.

Please see the photo here: GitHub README, Section "Lcd Display".enter image description here

  1. You write the first line of a "text" to the second row. Then you clean the screen.

  2. After a delay you write the first line to the first row and a the second line of the text to the second row. Then follows another clean and delay.

  3. Then you write the second line to the first row and the third line to the second row. And so on ...

When the end of the text is reached the whole process starts again from the beginning.

That way the impression of an "vertical moving" text is accomplished.

The code I have written:

#include <LiquidCrystal.h>

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

void setDisplay(String lineValue, int lineNumber, int waitUntilClear, boolean clearScreen) {
  lcd.setCursor(0, lineNumber),
  lcd.print(lineValue); 

  delay(waitUntilClear);

  if (clearScreen == true) {
   lcd.clear(); 
  }
}

void setup() {
  lcd.begin(16, 2);
}

void loop() {
  const int DELAY = 3000;
  const int COUNT_ELEMENTS = 12;
  
  String messages[COUNT_ELEMENTS] = {
    "",
    "Furniture Store",
    " MEYER & MILLER",
    "",
    "  Contact us!",
    "",
    " -- Email ----- ",
    "[email protected]",
    "",
    " -- Phone ----- ",
    " 000 123456",
    ""
  };

  for (int i = 0; i < COUNT_ELEMENTS - 1; i++) {
    setDisplay(messages[i], 0, 0, false);
    setDisplay(messages[i + 1], 1, DELAY, true);
  } 
}

Works fine and by using an additional function I could avoid code-redundancies mostly.

But anyway: If someone has an idea how to improve my code or even doing it completely different in a better way, then I would appreciate his/her comment or answer.

Following idea:

You have a LCD-display with 2 rows.

Please see the photo here: GitHub README, Section "Lcd Display".

  1. You write the first line of a "text" to the second row. Then you clean the screen.

  2. After a delay you write the first line to the first row and a the second line of the text to the second row. Then follows another clean and delay.

  3. Then you write the second line to the first row and the third line to the second row. And so on ...

When the end of the text is reached the whole process starts again from the beginning.

That way the impression of an "vertical moving" text is accomplished.

The code I have written:

#include <LiquidCrystal.h>

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

void setDisplay(String lineValue, int lineNumber, int waitUntilClear, boolean clearScreen) {
  lcd.setCursor(0, lineNumber),
  lcd.print(lineValue); 

  delay(waitUntilClear);

  if (clearScreen == true) {
   lcd.clear(); 
  }
}

void setup() {
  lcd.begin(16, 2);
}

void loop() {
  const int DELAY = 3000;
  const int COUNT_ELEMENTS = 12;
  
  String messages[COUNT_ELEMENTS] = {
    "",
    "Furniture Store",
    " MEYER & MILLER",
    "",
    "  Contact us!",
    "",
    " -- Email ----- ",
    "[email protected]",
    "",
    " -- Phone ----- ",
    " 000 123456",
    ""
  };

  for (int i = 0; i < COUNT_ELEMENTS - 1; i++) {
    setDisplay(messages[i], 0, 0, false);
    setDisplay(messages[i + 1], 1, DELAY, true);
  } 
}

Works fine and by using an additional function I could avoid code-redundancies mostly.

But anyway: If someone has an idea how to improve my code or even doing it completely different in a better way, then I would appreciate his/her comment or answer.

Following idea:

You have a LCD-display with 2 rows.

enter image description here

  1. You write the first line of a "text" to the second row. Then you clean the screen.

  2. After a delay you write the first line to the first row and a the second line of the text to the second row. Then follows another clean and delay.

  3. Then you write the second line to the first row and the third line to the second row. And so on ...

When the end of the text is reached the whole process starts again from the beginning.

That way the impression of an "vertical moving" text is accomplished.

The code I have written:

#include <LiquidCrystal.h>

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

void setDisplay(String lineValue, int lineNumber, int waitUntilClear, boolean clearScreen) {
  lcd.setCursor(0, lineNumber),
  lcd.print(lineValue); 

  delay(waitUntilClear);

  if (clearScreen == true) {
   lcd.clear(); 
  }
}

void setup() {
  lcd.begin(16, 2);
}

void loop() {
  const int DELAY = 3000;
  const int COUNT_ELEMENTS = 12;
  
  String messages[COUNT_ELEMENTS] = {
    "",
    "Furniture Store",
    " MEYER & MILLER",
    "",
    "  Contact us!",
    "",
    " -- Email ----- ",
    "[email protected]",
    "",
    " -- Phone ----- ",
    " 000 123456",
    ""
  };

  for (int i = 0; i < COUNT_ELEMENTS - 1; i++) {
    setDisplay(messages[i], 0, 0, false);
    setDisplay(messages[i + 1], 1, DELAY, true);
  } 
}

Works fine and by using an additional function I could avoid code-redundancies mostly.

But anyway: If someone has an idea how to improve my code or even doing it completely different in a better way, then I would appreciate his/her comment or answer.

Source Link
michael.zech
  • 4.5k
  • 8
  • 33
  • 56

Arduino: Vertical "moving" text on a LCD-display

Following idea:

You have a LCD-display with 2 rows.

Please see the photo here: GitHub README, Section "Lcd Display".

  1. You write the first line of a "text" to the second row. Then you clean the screen.

  2. After a delay you write the first line to the first row and a the second line of the text to the second row. Then follows another clean and delay.

  3. Then you write the second line to the first row and the third line to the second row. And so on ...

When the end of the text is reached the whole process starts again from the beginning.

That way the impression of an "vertical moving" text is accomplished.

The code I have written:

#include <LiquidCrystal.h>

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

void setDisplay(String lineValue, int lineNumber, int waitUntilClear, boolean clearScreen) {
  lcd.setCursor(0, lineNumber),
  lcd.print(lineValue); 

  delay(waitUntilClear);

  if (clearScreen == true) {
   lcd.clear(); 
  }
}

void setup() {
  lcd.begin(16, 2);
}

void loop() {
  const int DELAY = 3000;
  const int COUNT_ELEMENTS = 12;
  
  String messages[COUNT_ELEMENTS] = {
    "",
    "Furniture Store",
    " MEYER & MILLER",
    "",
    "  Contact us!",
    "",
    " -- Email ----- ",
    "[email protected]",
    "",
    " -- Phone ----- ",
    " 000 123456",
    ""
  };

  for (int i = 0; i < COUNT_ELEMENTS - 1; i++) {
    setDisplay(messages[i], 0, 0, false);
    setDisplay(messages[i + 1], 1, DELAY, true);
  } 
}

Works fine and by using an additional function I could avoid code-redundancies mostly.

But anyway: If someone has an idea how to improve my code or even doing it completely different in a better way, then I would appreciate his/her comment or answer.