I'm very new to Arduino, and it's been several years since I did any coding in C++ so I'm a little rusty.
I have an HD44780 16x2 LCD that I've been playing with. I'm attempting to get it to repeatedly scroll a message longer than the 16 characters available on the LCD.
I have it scrolling, but not quite like I want. The sketch is currently just scrolling an all caps alphabet, and I'm trying to code it such that it would reach the end and immediately start back at the beginning and at some point would look like:
Instead, what I'm getting is:
and eventually all the way down to:
Once the final Z scrolls off, then it will start back at the beginning, however, it starts with A all the way to the left like:
I've rewritten the code several different ways, and continually get the same result although the code seems to get tighter each time. here is the current version:
// LiquidCrystal display with:
// rs on pin 12
// rw on pin 11
// enable on pin 10
// d4, d5, d6, d7 on pins 5, 4, 3, 2
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
int delayTime = 300;
char string = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz";
char string2 = "ABCDEFGHIJKLMNOP QRSTUVWXYZ ";
char string3 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; //sizeof = 27
int pos = 0;
int i = 0;
int grab = 0;
// Print a message to the LCD.
grab = pos;
for(i=0; i<16; i++)
grab=(grab >= sizeof(string3))?0:grab;
display = string3[grab];
if(pos > sizeof(string3))
pos = 0;
What am I missing?