LCD blinks but no output

I'm testing my LCD 16x2 using a test sketch. It blinks three times as it should and then nothing.

  for(int i = 0; i< 3; i++)
  {
    lcd.backlight();
    delay(250);
    lcd.noBacklight();
    delay(250);
  }
  lcd.backlight(); // finish with backlight on  

  lcd.setCursor(0,0); //Start at character 4 on line 0
  lcd.print("Hello, world!");
  delay(1000);
  lcd.setCursor(0,1);
  lcd.print("Hi Arduino LCD!!");
  delay(8000);

What sort of LCD is it? There must be dozen of types. Post your whole code so that we know which libraries that you are using.

Does the adjusting the contrast pot have any effect?

I will venture a guess that it is a 1602 or 2004 type character LCD with a hd44780 controller and I2C backpack. If that is true, install and use the hd44780 library. The library is available from the Library Manager. Use the hd44780I2C_exp class. The library will auto detect the I2C address and backpack to LCD pin mapping for you. Closest thing to plug and play that you can get for those LCDs.

hcccs:
I'm testing my LCD 16x2 using a test sketch. It blinks three times as it should and then nothing.

  for(int i = 0; i< 3; i++)

{
   lcd.backlight();
   delay(250);
   lcd.noBacklight();
   delay(250);
 }
 lcd.backlight(); // finish with backlight on

lcd.setCursor(0,0); //Start at character 4 on line 0
 lcd.print("Hello, world!");
 delay(1000);
 lcd.setCursor(0,1);
 lcd.print("Hi Arduino LCD!!");
 delay(8000);

I find that hard to believe.

Of course seeing the entire program, a copy and paste version - not a retyped fragment, might help me change my mind.

On the other hand it's nice to see that you did put your fragment in a 'code box'!

Don

Don

Here's my LCD and code:
I hope the picture comes thru.

Link to picture: 20190308 160929 — Postimages

/* YourDuino.com Example Software Sketch
 16 character 2 line I2C Display
 Backpack Interface labelled "YwRobot Arduino LCM1602 IIC V1"
 terry@yourduino.com */

/*-----( Import needed libraries )-----*/
#include <Wire.h>  // Comes with Arduino IDE
// Get the LCD I2C Library here: 
// https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
// 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(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // original parameters 
	LiquidCrystal_I2C lcd(0x27, 6, 5, 4, 7, 8, 9, 10, 3, POSITIVE); // my parameters
	
/*-----( Declare Variables )-----*/
//NONE

void setup()
{
  Serial.begin(9600);  // Used to type in characters

  lcd.begin(16,2);   // initialize the lcd for 16 chars 2 lines, turn on backlight

// ------- Quick 3 blinks of backlight  -------------
  for(int i = 0; i< 3; i++)
  {
    lcd.backlight();
    delay(250);
    lcd.noBacklight();
    delay(250);
  }
  lcd.backlight(); // finish with backlight on  

//-------- Write characters on the display ------------------
// NOTE: Cursor Position: (CHAR, LINE) start at 0  
  lcd.setCursor(0,0); //Start at character 4 on line 0
  lcd.print("Hello, world!");
  delay(1000);
  lcd.setCursor(0,1);
  lcd.print("HI!YourDuino.com");
  delay(8000);  

// 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.clear();
  lcd.setCursor(0,0); //Start at character 0 on line 0
  lcd.print("Use Serial Mon");
  lcd.setCursor(0,1);
  lcd.print("Type to display");  

}


void loop() 
{
  {
    // when characters arrive over the serial port...
    if (Serial.available()) {
      // wait a bit for the entire message to arrive
      delay(100);
      // clear the screen
      lcd.clear();
      // read all the available characters
      while (Serial.available() > 0) {
        // display each character to the LCD
        lcd.write(Serial.read());
      }
    }
  }

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


/* ( THE END ) */
// LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // original parameters
	LiquidCrystal_I2C lcd(0x27, 6, 5, 4, 7, 8, 9, 10, 3, POSITIVE); // my parameters

Your constructor is crap.

There are only two "typical" backpacks

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // MOST common
LiquidCrystal_I2C lcd(0x27, 6, 5, 4, 0, 1, 2, 3, 7, POSITIVE);  // LESS common

The 0x27 is the normal address for PCF8574
Use 0x3F if you have PCF8574A

There are diagnostic programs that will identify the I2C address e.g. 0x20-0x27, 0x38-0x3F

If you use the "hd44780.h" library, it will detect the correct address and correct wiring automatically.

David.

I'm still hung up on the 'three blinks' part working properly (or at all) . . .

// ------- Quick 3 blinks of backlight  -------------
  for(int i = 0; i< 3; i++)
  {
    lcd.backlight();
    delay(250);
    lcd.noBacklight();
    delay(250);
  }

It seems to me that the for loop should somehow be dealing with 'i'.

Don

EDIT: Never mind - I guess I didn't get enough sleep last night.

The blink backlight loop shows that he has got the correct I2C Slave address (0x27) and the correct PCF8574 backlight pin (3). And the chip is PCF8574 and not PCF8574A.

So I would expect the Malpartida library code to work with this constructor:

//                   addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // MOST common

David.

david

It works but a few things are still unclear. The en, rw, rw on my LCD has pin numbers 6, 5, 4 if I start counting from 1 but the working numbers are 2, 1, 0. What is bl, blpol? As can be seen from the photo there's a strange character after the text. What could it be?

Picture: lcd — Postimages

Did you use lcd.println()? The println() function does not work on !CDs. Use print() and setCursor() to control print position.

The pin numbers in the lcd constructor refer to the pin numbers of the I2C expander chip on the backpack.

They refer to the port numbers of the Port Expander chip e.g P0 .. P7

You should never refer to the pin numbers on the chip package (except when actually wiring them)
Likewise you refer to PORT numbers on an AVR chip e.g. PD0 .. PD7 and not the pins of the TQFP-32 package.

David.

I now realize that I mis worded my post. I did mean port numbers. Thanks for the correction.

Yes, I realised that that was what you meant to say.

David.

The blink backlight loop shows that he has got the correct I2C Slave address (0x27) and the correct PCF8574 backlight pin (3).

And the active backlight circuit control level was correct as well (fm calls it polarity, and POSITIVE in this case)

There are only two "typical" backpacks

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // MOST common

LiquidCrystal_I2C lcd(0x27, 6, 5, 4, 0, 1, 2, 3, 7, POSITIVE);  // LESS common

I have seen backpacks labeled "mjkdz" that are fairly common and use a active low backlight circuit.
with newLiquidCrystal, it would use this constructor:

LiquidCrystal_I2C lcd(0x27, 6, 5, 4, 0, 1, 2, 3, 7, NEGATIVE);

While most libraries that support PCF8574 based backpacks use the output port # or Pn number, or internal bit numbers of the of the i/o register connected to LCD functional pins in a fixed order, I have seen one library that seemed pretty odd to me. The eight pin positions represented the 8 i/o pins on the PCF8574 (i.e. P0 to P7) and the numbers in the constructor were the physical pin number of the LCD module that was connected to that Pn pin.
i.e. If P0 was connected to the RS pin then the first pin number would be 4
I can't remember how the backlight pin value was handled, I but think it was either 15 or 16

My overall suggestion, is to run the hd44780 library over the newLiquidCrystal library.
It is faster and has many better capabilities, and is much easier to install.

--- bill