Vertical LCD scroll

Looked for simple solutions on line. No such luck, so I spent a few hours with this solution that can be expanded on to add full up/down control.

#include <avr/pgmspace.h>
#include <LiquidCrystal.h>

/*

  • sketch to scroll text strings vertically on lcd
  • currently auto scroll from 0 - 10 and loops
  • can be modified to permit button scrolling by
  • using button to inc/dec i
    */

LiquidCrystal lcd(8,9,4,5,6,7); // set lcd pins

prog_char string_0 PROGMEM = “String 0”; // Strings to store text to display
prog_char string_1 PROGMEM = “String 1”;
prog_char string_2 PROGMEM = “String 2”;
prog_char string_3 PROGMEM = “String 3”;
prog_char string_4 PROGMEM = “String 4”;
prog_char string_5 PROGMEM = “String 5”;
prog_char string_6 PROGMEM = “String 6”;
prog_char string_7 PROGMEM = “String 7”;
prog_char string_8 PROGMEM = “String 8”;
prog_char string_9 PROGMEM = “String 9”;
prog_char string_10 PROGMEM = “String 10”;
prog_char string_11 PROGMEM = “”;

// table to read your strings.
PROGMEM const char *string_table =
{
string_0,
string_1,
string_2,
string_3,
string_4,
string_5,
string_6,
string_7,
string_8,
string_9,
string_10,
string_11
};

char buffer1[30]; // buffer for display line 0 large enough for the largest string it must hold
char buffer2[30]; // buffer for display line 1 large enough for the largest string it must hold

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

void loop()
{
for (int i = 0; i < 13; i++) // i count for string number to display
{
strcpy_P(buffer1, (char*)pgm_read_word(&(string_table*))); // read PROGMEM string sequence*
strcpy_P(buffer2, (char*)pgm_read_word(&(string_table[i + 1]))); // read PROGMEM string sequence with +1 offset

  • lcd.clear(); // clear lcd*
  • lcd.setCursor(0,0); // set lcd cursor to row 0*
  • lcd.print(buffer1); // print buffer 1 contents*
  • if (i < 11) // check i count is < 11*
  • {*
  • lcd.setCursor(0,1); // set lcd cursor to row 1*
  • lcd.print(buffer2); // print buffer 2 contents*
  • delay(1500); // delay for 1.5 seconds*
  • }*
  • else*
  • {*
  • return; // if i count < 11, return*
  • }*
  • }*
    }
    //~~~~~~~~~~~~~~~~~~~~~~ eof ~~~~~~~~~~~~~~~~~~~~~~~
    [/quote]

Hint: Put your code in a ‘code’ box and it will miraculously become legible. The icon looks like a scroll with < > symbols.

Don

According to the Arduino Reference on PROGMEM:

Flash (PROGMEM) memory can only be populated at program burn time. You can’t change the values in the flash after the program has started running.

So this technique could not be used to view data recorded by a running sketch?