Updated Arduino LCD Library

Posted by jiGGaK on March 9th, 2008

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.

Neil September 13th, 2008

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.


Lcd lcd = Lcd(16, FUNCTION_4BIT | FUNCTION_2LINE);

char mightybig[]= "Be Awesome!";

void setup()


void loop()

Neil September 10th, 2008


Just so you know, the module that I am using is this one: http://www.nkcelectronics.com/16x2-lcd-module-while-characters-blue-backli162.html

I set the RW pin to 2, and I am using it in 4-bit mode.

jiGGaK September 10th, 2008

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.

Neil September 9th, 2008

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?