Skip to content

awsh.org Posts

scrolling one line on a 16×2 lcd

I’m working on an arduino morse code keyer and will be using a 16×2 lcd like this:

I want to have some static text on the top line, while the bottom line scrolls. The built in arduino lcd library will do scrolling, but not a single line. There are other code examples showing how to do this, but they all seem overly complicated to me.

Here is the solution that I came up with.

The code basically keeps a 16 character string in line2 at all times. It starts with 16 spaces. Each call of update_lcd_buffer will remove the first character from the string and add the supplied character to the end of the string. It does this by creating a pointer to the second character of the string called buffer. It then copies the contents of the buffer back to the line2 variable. Then it adds the new character to the end of the string. Then it updated the lcd with the new data.

I don’t know if this is the best way of doing this, but it works well for my purpose and it is much simpler and more concise code than most of the examples I’ve seen.

 

 

Leave a Comment