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:
"...XYZABC..."
Instead, what I'm getting is:
"...XYZ "
and eventually all the way down to:
"Z "
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:
"ABC..."
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:
#include <LiquidCrystal.h>
#include <String.h>// 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 = 27int pos = 0;
char display[16];
int i = 0;
int grab = 0;void setup()
{
// Print a message to the LCD.
//lcd.print(sizeof(string3));}
void loop()
{
generateDisplay();
lcd.home();
lcd.clear();
lcd.print(display);
delay(delayTime);}
void generateDisplay()
{
grab = pos;
for(i=0; i<16; i++)
{
grab=(grab >= sizeof(string3))?0:grab;
display = string3[grab];
- grab++;*
- }*
- pos++;*
- if(pos > sizeof(string3))*
- {*
- pos = 0;*
- }*
}
[/quote]
What am I missing?
Thanks
Mitch