LCD Example code won't work at my pc

Dear enthusiasts,

I’m working on a small arduino project, which includes a 16x2 LCD.
I decided not to use a I2C board because then the LCD won’t fit the housing.

I bought a brand new 16x2 LCD and soldered all the leads as described “here” on the arduino pages.
I always use the “hello world” project to test all the leads and connections.
Therefore I hooked it all up to my computer and run the “hello world” code i copied from the arduino pages.

I noticed that the code provided wont work.
I tried it on a uno and on a mega but the error stays the same.
When i include the I2C library it will compile without any errors, but the LCD stays dark.
It seems that my library doesn’t do the trick…

I also removed the complete Arduino program and reinstalled it again but the problem stays the same. I used 4x20 LCD I2C in the past without any problems…

What is going wrong?

the code used:

#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);
}

Error message:

  • This report would have more information with*
  • “Show verbose output during compilation”*
  • enabled in File > Preferences.*
    Arduino: 1.0.6 (Windows 7), Board: “Arduino Mega 2560 or Mega ADK”
    C:\Users\Thuis\Documents\Arduino\libraries\LiquidCrystal\I2CIO.cpp: In member function ‘int I2CIO::begin(uint8_t)’:
    C:\Users\Thuis\Documents\Arduino\libraries\LiquidCrystal\I2CIO.cpp:61: error: ‘Wire’ was not declared in this scope
    C:\Users\Thuis\Documents\Arduino\libraries\LiquidCrystal\I2CIO.cpp: In member function ‘uint8_t I2CIO::read()’:
    C:\Users\Thuis\Documents\Arduino\libraries\LiquidCrystal\I2CIO.cpp:117: error: ‘Wire’ was not declared in this scope
    C:\Users\Thuis\Documents\Arduino\libraries\LiquidCrystal\I2CIO.cpp: In member function ‘int I2CIO::write(uint8_t)’:
    C:\Users\Thuis\Documents\Arduino\libraries\LiquidCrystal\I2CIO.cpp:140: error: ‘Wire’ was not declared in this scope

Looks like someone installed the LiquidCrystalI2C library as LiquidCrystal. That library is being used in place of the built-in LiquidCrystal library and it requires the Wire library.

Re-name the library to LiquidCrystalI2C and re-start the IDE.

Stays DARK? Like the backlight isn't lighting up? Sounds like a wiring issue to me. Even if it's completely blank, if the backlight has power, it should light up.

thanks John, got it working again.

Ill have to check the display and wiring again i think the display is broken

The most common cause of issues is either a soldering fault or the contrast pot not connected or incorrectly connected.

Am I missing something as I do not see a baklight pin defined and "lcd.backlight();"

The LCD hello world example at http://arduino.cc/en/Tutorial/LiquidCrystal (which the OP is using to test the LCD) is confusing, as it does not have you wire the backlight pin.

I found with my LCD that I needed to wire the backlight on as otherwise it just looked dead. On the typical 16 pin interface, connect the last two pins to +5v and ground respectively to turn the backlight on.

You can also control the backlight from a digital IO pin, if desired.

If you instead can get it to light up but it looks like it has all blocks or it looks like there is no text, it is a contrast problem. You need to have a pot wired correctly. I found that I could use a 1k pot instead of a 10k pot for contrast control, so you don't need to slavishly follow the hello world example.

However, you cannot control contrast from a PWM IO pin without introducing errors on the LCD. This seems to be something with the PWM going to the V0 pin on the LCD. If you (or anyone on this forum!) have thoughts on how to solve this issue, I would be grateful for your advice: I recently posted about this issue and potential solutions as an add on to the post here: http://forum.arduino.cc/index.php?topic=91529.0

Good luck getting your LCD to work!

MakerSelf: I found with my LCD that I needed to wire the backlight on as otherwise it just looked dead. On the typical 16 pin interface, connect the last two pins to +5v and ground respectively to turn the backlight on.

I really feel stupid, after reading this I took a closer look and found out that pin 15 and 16 even are marked A and K.

Yesterday i bought two new ones and just now i lid up the one i thought that was dead...

thanx for all the input.

Glad you solved it and to be of help! :D