LiquidCrystal.h seems to lock up Arduino sketch [SOLVED]

Hello,

I have a HD44780 display that I am trying to use with my Arduinos. To this end, I have imported the LiquidCrystal.h header as described in http://www.arduino.cc/en/Tutorial/LiquidCrystal, however, the moment I upload a sketch that includes this header, the Arduino appears to lock up. Nothing happens on the screen, and the LED on pin 13 doesn't blink (it stays on continuously) despite the addition of

digitalWrite(led, HIGH);
delay(500);
digitalWrite(led, LOW);
delay(500);

to the loop() function. My conclusion is that there is an unresolved issue with LiquidCrystal.h that causes a lock, or possibly an infinite loop. This happens on both my Mega and on my Nanos (I haven't tested with the Uno, because I can't seem to locate it at the moment). What's your take on this?

For the sake of completeness, here is the code(s) I have tested:

#include <LiquidCrystal.h>;

int led = 13;

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup () {
  lcd.begin(16, 2);
  lcd.print("hello, world");
  pinMode(led, OUTPUT);
}
  
void loop () {
  lcd.setCursor(0, 1);
  lcd.print(millis()/1000);
  digitalWrite(led, HIGH);
  delay(500);
  digitalWrite(led, LOW);
  delay(500);
}
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);
}

I purchased a HD44780-compatible LCD on eBay. http://www.ebay.com/itm/1PCS1602-New-1602-16x2-HD44780-Character-LCD-Display-Module-LCM-blue-blacklight-/300881377539

Used the LiquidCrystal.h without any problems.

I have an Arduino Uno R3 also purchased on eBay.

In my sketch, LiquidCrystal lcd(4,5,6,7,8,9);

The code you have in your loop() function is unnecessary.

That appears to be very similar to mine, probably the same one... However, I think the display itself works, but the library does not.

Edit: Sorry, I was playing League while replying to your post, so I did not see the last part. It is there because it's there in the tutorial I linked to, and I added the LED blink to determine whether or not it was actually running, which it turns out it isn't (as the LED stays on continuously).

Interestingly, if I add digitalWrite(led, LOW); to the setup() function, the LED still stays on. So this must mean that the sketch does not execute AT ALL, reinforcing the basis for my theory that there is a problem with LiquidCrystal.h.

However, I think the display itself works, but the library does not.

So are you saying that the library that has been unchanged since Arduino v017 has suddenly developed a flaw?

My conclusion is that there is an unresolved issue with LiquidCrystal.h

Have you considered the possibility that there is a problem with the installation of your copy of the library or perhaps with the installation of your copy of the IDE itself?

Don

The code you have in your loop() function is unnecessary.

Unless he happens to want to display the number of seconds since he started the sketch and he wants to flash his LED.

Don

floresta:
Unless he happens to want to display the number of seconds since he started the sketch and he wants to flash his LED.

Don

I thought the objective was to figure out why he isn't able to write to his display.

I thought the objective was to figure out why he isn't able to write to his display.

In that case you are absolutely correct. It seemed to me that he was more concerned with the sketch 'not running' and in blaming it on the library when most likely the problem lies elsewhere. I overlooked the part where he said that nothing happens on the LCD.

The code in loop() is indeed unnecessary (actually it is undesirable) if one wants to verify that the LCD is connected properly and I frequently recommend using a blank loop during LCD troubleshooting.

He correctly added a blinking LED to see if the sketch was running but what he should have done was also eliminate the part of loop that displays the up-time (or anything else) on the LCD.

Don

You are, of course, quite right Don. The lower the complexity, the easier it is to troubleshoot...

The problem resolved itself when I copied the header file from a different computer that was running an earlier version of the IDE.

So are you saying that the library that has been unchanged since Arduino v017 has suddenly developed a flaw?

Not exactly... I was more saying that it might have an unresolved problem that has always been there, but that only surfaces in extremely specific circumstances. The reason why I was so sure it was not a problem with my installation is that absolutely everything else is working perfectly; however, it does appear to have been my copy after all.