I have just recently started using a Mega 2560 clone, although I have many years of experience using assembly language on PICs.
I have a Midas 16x1 LCD which I am using the "Hello world" sketch to write to; the problem is that only the first 8 characters from the LHS display the correct output; the remaining characters are dark.
I am using all the control lines and have tried both 4-bit and 8-bit addressing options.
When I originally started playing with it with a PIC some years ago, I had exactly the same problem and Midas told me that it had to be treated as an 8x2 display; problem solved.
I have tried lcd.begin (16,1) and (8,2) but still no joy. Any ideas?
Is there any documentation as to how the lcd.begin instruction works, at an assembly language level?
In addition to specifying that the device is 8x2 you have to re-position the cursor to the start of the 'second' row in order to display the characters on the right half of the display.
If you want see how to deal with the display at the assembly language level then follow the LCD Programming Examples link at Don's Collected Technical Information. The LCD Addressing link at the same location explains the 16x1 situation.
EDIT: I have some ancient PIC assembly language code around here somewhere but if you understand PIC assembly language you should have no problem following the AVR code.
Don
I had the same issue a few months ago, I didn't know at the time that cheap 1x16 LCD works like 2x8 LCD. The default library doesn't handle split 1x16 LCD well, and I had a good solution from someone:
bperrybap:
Yeah, that type of display is pretty difficult to use with "standard" arduino LiquidCrystal type libraries.
I would go so far to say it actually sucks.
However, the hd44780 library can do automatic line wrapping to make it work the way you want it work.
There is no sort of word wrapping in hd44780; it is very simple.
When enabled, it wraps to the next line when characters get to the end of the current line
and back to the first line if on the bottom line.
There is no scrolling capability.
The hd44780 library should be smart enough to handle that type of display.
What you will want to do is initialize the display as an 8x2 display.
Then tell the library to do automatic line wrapping by calling lcd.lineWrap()
After that, you can treat the display as if was a 16x1, including using setCursor(col, row)
when col > 7
i.e. you can set the cursor col to any position between 0 and 15 on row 0
and it will work as you want it to work. Even though the display is really 8x2, it will work as a 16x1
The hd44780 library can be installed directly from the GUI library manager.
There is even a LineWrap demo sketch example to demonstrate this.
Read the comments in it, but basically you just need to set the geometry to 8x2.
If you are currently using the LiquidCrystal library you will want to use the hd44780_pinIO class in the hd44780 library. See the examples for what header files you need to include and the constructor parameters.
Start by looking at the HelloWorld sketch.
See the hd44780 github page for more information: GitHub - duinoWitchery/hd44780: Extensible hd44780 LCD library
And also read the wiki: Home · duinoWitchery/hd44780 Wiki · GitHub
as it explains where the examples are for each i/o class.
Use the IDE GUI library manager to do the install, do not install it from a zip file.
--- bill
tl;dr use alternative library mentioned at the bottom of the above quote, and set it as 2x8 LCD, it will wrap text correctly and make your 1x16 LCD look like a 1x16 LCD.
wilykat:
I had the same issue a few months ago, I didn't know at the time that cheap 1x16 LCD works like 2x8 LCD. The default library doesn't handle split 1x16 LCD well, and I had a good solution from someone:
tl;dr use alternative library mentioned at the bottom of the above quote, and set it as 2x8 LCD, it will wrap text correctly and make your 1x16 LCD look like a 1x16 LCD.
Too Long to Read? Seriously?
I don't have sympathy for those that choose to not read, especially when in this case it would take what 30 seconds?
--- bill
Thanks to everyone for their help; I've successfully used led.setCursor and can now write to all 16 characters.
I've also got a 20x4 LCD for another project which was going to be PIC-controlled, hopefully that should not be a problem now