backlight goes out what am i doing wrong

when i upload this code the backlight on my display goes out and hello world does not appear i am in the egg stage of arduino so a complete noob at this. i had it working using the regular way of connecting the display, but have installed an I2c adapter for the display to save some pins. before uploading this code the backlight is on, i know its something stupid i am missing please enlighten me as to what it is that i am missing. thanks james

//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x20 for a 16 chars and 2 line display

void setup()
  lcd.init();                      // initialize the lcd 
  // Print a message to the LCD.
  lcd.print("Hello, world!");

void loop()


You will find readers of this Forum much more helpful if you follow the guidelines printed in the first two posts at the top of this Forum. For example, you should always post your code using standard C formatting. You can do this by placing your cursor in the Source Code Window of the Arduino IDE and pressing Ctrl-T. Then use the source code tag (i.e., the '#' symbol) to surround your newly-formatted source code with the code markup tags. These simple steps make it easier for the rest of us to help you.

i modified the code like you said now do you have any suggestions to what is making my backlight go out when this code is uploaded thanks james

you are using the 20 character, 4 line LCD?

Do you have a link to the LCD and the I2C backpack your using. One of the backpacks I have (from ebay) needed the library modifying as the pin order was different (reversed if my memory serves me correctly).

yes i am using the 20x4 lcd the address was found using the I2c scanner that was suggested from this site it returned the 0x27 address.

the adapter is this one

i have tried the 0x3f address like the sellers e-bay ad says nothing happens with it not even the backlight going out so i am pretty sure the 0x27 address is the correct one thanks for any help james

To be sure about the I2C address only connect up the LCD and run the sketch on this page. This should find the backpack and report it’s address.
Try again if the address is different to the one your already trying and if that fails then backup your current LiquidCrystal_I2C library and try the attached one. (4.51 KB)

i used this code and it works thanks for all the help !!!

/* Example Software Sketch
 20 character 4 line I2C Display
 Backpack Interface labelled "LCM1602 IIC  A0 A1 A2" */

/*-----( Import needed libraries )-----*/
#include <Wire.h>  // Comes with Arduino IDE
// Get the LCD I2C Library here: 
// Move any other LCD libraries to another folder or delete them
// See Library "Docs" folder for possible commands etc.
#include <LiquidCrystal_I2C.h>

/*-----( Declare Constants )-----*/
/*-----( Declare objects )-----*/
// set the LCD address to 0x27 for a 20 chars 4 line display
// Set the pins on the I2C chip used for LCD connections:
//                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x20, 4, 5, 6, 0, 1, 2, 3, 7, NEGATIVE);  // Set the LCD I2C address

/*-----( Declare Variables )-----*/

void setup()   /*----( SETUP: RUNS ONCE )----*/
  Serial.begin(9600);  // Used to type in characters

  lcd.begin(20,4);         // initialize the lcd for 20 chars 4 lines

// NOTE: Cursor Position: CHAR, LINE) start at 0  
  lcd.setCursor(3,0); //Start at character 4 on line 0
  lcd.print("Hello, world!");
  lcd.print("From YourDuino");
  lcd.print("20 by 4 Line Display");
// Wait and then tell user they can start the Serial Monitor and type in characters to
// Display. (Set Serial Monitor option to "No Line Ending")
  lcd.setCursor(0,0); //Start at character 0 on line 0
  lcd.print("Start Serial Monitor");
  lcd.print("Type chars 2 display");   

}/*--(end setup )---*/

void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
    // when characters arrive over the serial port...
    if (Serial.available()) {
      // wait a bit for the entire message to arrive
      // clear the screen
      // read all the available characters
      while (Serial.available() > 0) {
        // display each character to the LCD

}/* --(end main loop )-- */

/* ( THE END ) */