Jump to content

I 'm trying to create a vertical scroll sketch using arduino uno and a 20x4 LCD


G+_Jorge Cornejo
 Share

Recommended Posts

20160209_154713.mp4.gif

I'm trying to create a vertical scroll sketch using arduino uno and a 20x4 LCD. Tried several things and I am not getting any results. Wondering if you guys can take a look at the code and give me some pointers on how to proceed.

 

~~~~~~~~~~~~~~~~~~~~~~~~~

 

#include

#include

#include

 

#define I2C_ADDR 0x27 // LCD address

#define Rs_pin 0 // Assign pins between I2C and LCD

#define Rw_pin 1

#define En_pin 2

#define BACKLIGHT_PIN 3

#define D4_pin 4

#define D5_pin 5

#define D6_pin 6

#define D7_pin 7

 

//#define P(str) (strcpy_P(p_buffer, PSTR(str)), p_buffer)

 

LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

 

const char string_0[] PROGMEM = "String Text 0"; // list of strings that will be stored for display in vertical scroll

const char string_1[] PROGMEM = "String Text 1";

const char string_2[] PROGMEM = "String Text 2";

const char string_3[] PROGMEM = "String Text 3";

const char string_4[] PROGMEM = "String Text 4";

const char string_5[] PROGMEM = "String Text 5";

const char string_6[] PROGMEM = "String Text 6";

const char string_7[] PROGMEM = "String Text 7";

const char string_8[] PROGMEM = "String Text 8";

const char string_9[] PROGMEM = "String Text 9";

const char string_10[] PROGMEM = "String Text 10";

const char string_11[] PROGMEM = "String Text 11";

const char string_12[] PROGMEM = "String Text 12";

const char string_13[] PROGMEM = "String Text 13";

const char string_14[] PROGMEM = "String Text 14";

const char string_15[] PROGMEM = "String Text 15";

const char string_16[] PROGMEM = "";

 

const char string_table[] = //Array of strings to display in a vertical scroll

{

string_0,

string_1,

string_2,

string_3,

string_4,

string_5,

string_6,

string_7,

string_8,

string_9,

string_10,

string_11,

string_12,

string_13,

string_14,

string_15,

string_16

};

 

char buffer1[20]; // buffer for display line 2 large enough for the largest string it must hold

char buffer2[20]; // buffer for display line 3 large enough for the largest string it must hold

 

void setup()

{

lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);

lcd.setBacklight(HIGH);

lcd.begin(20,4);

delay(1000);

}

 

void loop()

{

for (int i = 0; i < 17; i++) // i count for string number to display

{

strcpy_P(buffer1, (char)pgm_read_word(&(string_table[10]))); // read PROGMEM string sequence

strcpy_P(buffer2, (char*)pgm_read_word(&(string_table[i + 1]))); // read PROGMEM string sequence w/ +1 offset

lcd.clear(); // clear lcd

lcd.setCursor(0,1); // set lcd cursor to row 2

lcd.print(buffer1); // print buffer 1 contents

if (i < 17) // check i count is < 17

{

lcd.setCursor(0,2); // set lcd cursor to row 3

lcd.print(buffer2); // print buffer 2 content

delay(500); // delay

}

else

{

return; // if i count < 17, return

}

}

}

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Link to comment
Share on other sites

 Share

×
×
  • Create New...