I received an email from Keith Neufeld (awesome electronics blog) about my Arduino LCD library with some tips on how to improve it. So over the weekend I dived in and did just that.
Specifically, this version removes the hard coded delays after each command is sent to the LCD and checks the LCD’s busy flag. This is a cleaner approach and should mean that the library works more reliably with various LCD modules (hopefully). The setup method has been cleaned up as well to make initialization by instruction just work without any hacks.
Of course, this does mean that the RW pin on the LCD must be connected to the Arduino instead of connecting to ground.
As before, see the Arduino LCD Library page to get the latest version of the code.
Comments 4
I have been working with your library, but have been getting some odd results.
First of all, nothing works correctly unless I put delays after every call to the LCD. A 2-3 milli delay is all it takes. (A 1 milli delay doesn’t work.) Do I need to tell it to check the RW pin?
Posted 09 Sep 2008 at 10:17 pm ¶No you don’t need to manually check the busy flag… this should be done automatically.
The fact that it works after adding the 2-3 millisecond delay tells me that the busy flag checking isn’t working correctly. Tonight I’ll try another LCD module I have kicking around to see if I can replicate the problem.
However if you’re feeling adventurous you could have a look at Lcd.cpp file… there is a function there called check_bf() which I suspect is the culprit.
Posted 10 Sep 2008 at 8:53 am ¶Thanks!
Just so you know, the module that I am using is this one: http://www.nkcelectronics.com/16×2-lcd-module-while-characters-blue-backli162.html
I set the RW pin to 2, and I am using it in 4-bit mode.
Posted 10 Sep 2008 at 9:38 am ¶Here is an example of what I have to do to get it working properly. If any of the delays are removed, I get jumbled characters after a little while.
Post a Comment