1602 LCD not working

Hi everyone,

My first post, I'm new to Arduino although have used a raspberry pi a fair bit.

Im having issues with getting my 16x2 LCD to display any text, it seems this is not uncommon but all the solutions I have found on the web haven't worked, so any help much appreciated.

Im using an Elegoo mega 2560 R3 with the desktop IDE on a Mac.
The LCD is a Qapass 1602a

I have attached pictures of the setup, and the code below.

The potentiometer alters the contrast from nothing to full dark to full light pixels (full character blocks) but only on the top row, nothing is displayed on the bottom row. The back light is on.

If I uncomment the code in the loop, the screen is totally blank.

I have checked the continuity of the wires from the solder on the bottom of the Arduino to the solder on the display, so am confident my connections are ok.

Any suggestions please?

Code:

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 8, 5, 4, 3, 2);

void setup() {
  pinMode(6,OUTPUT);
  analogWrite(6,90); //sweetspot for backlight without using a potentiometer.

  lcd.begin(16, 2);
  lcd.setCursor(0,0);
  lcd.print("hello, world!");
  delay(3000);
}

void loop() {
 // lcd.setCursor(0, 1);
 // lcd.print(millis()/1000);
}/code]

pics.zip (1010 KB)

JohnK75:
Any suggestions please?

Yes, attach pictures or follow the instructions and in-line them.

As "zip" files may auto-execute on Windoze systems, they are a security risk and people will not download or open them.

The analogWrite(6,90); in the code suggests a totally inappropriate way of connecting the contrast on pin 3. Use a potentiometer as a variable resistor - 10k will do but 1k is better - between pin 3 and ground but do not connect it to 5 V.

I can't figure out why you could get the blocks on the first line (correct contrast setting) but then

JohnK75:
If I uncomment the code in the loop, the screen is totally blank.

Oh wait on, I do know what that means! It likely would be blank if the display is actually being accessed, because that loop code does something completely foolish! But if the display is actually being accessed, you would have seen the "hello, world!". :roll_eyes:

We now recommend you install the HD44780 library from the IDE itself and work through the examples appropriate for your assembly rather than the original LiquidCrystal.h library.

Hi JohnK75,

I copy/pasted your code into my own IDE and uploaded it to my 16x2 LCD display powered by an Arduino Nano (with a 10 K pot meter whose wiper is connected with pin 3 of the LCD display - contrast pot.

configuration as on the picture at:

Code produced "hello world" on the display. I had to comment out the instructions pinMode (6, OUTPUT) and analogWrite(6,90); //sweetspot for backlight without using a potentiometer or else the display would show gibberish.

photoncatcher:
I copy/pasted your code into my own IDE and uploaded it to my 16x2 LCD display powered by an Arduino Nano (with a 10 K pot meter whose wiper is connected with pin 3 of the LCD display - contrast pot.

Ah! Very enterprising and helpful. :sunglasses:

Do make a point of not connecting the potentiometer to 5 V. Makes contrast setting twice as easy and saves a trifle of current. :grinning:

photoncatcher:
Code produced "hello world" on the display. I had to comment out the instructions pinMode (6, OUTPUT) and analogWrite(6,90); //sweetspot for backlight without using a potentiometer or else the display would show gibberish.

Now that is most peculiar! since pin 6 of the Arduino is not connected in any way to the LCD. :astonished:

Did you try removing the comment marks from the code in loop() to see the effect?

Thank you for the replies.

photoncatcher, I have rewired to your diagram, with and without the 5v to the pot (as per Paul__B's suggestion)and am still getting the same result as before.

Paul__B, Apologies for the .zip file, but the forum would not let me upload the .jpgs. but it would a zip, despite them being only ~250k each.

I have now installed the HD 44780 library as per your suggestion and will work through some examples.

I am however still confused as to why, what should be a simple hello world program will not work, and I have tried many examples including the one built in to the IDE.

Thanks again.

JohnK75:
Thank you for the replies.

photoncatcher, I have rewired to your diagram, with and without the 5v to the pot (as per Paul__B's suggestion)and am still getting the same result as before.

. . .

Thanks again.

Have you changed the constructor to agree with this new diagram? There is a discrepancy with respect to the LCD Enable pin.

Don

Thanks floresta, I had stripped the board down to try the hd44780 library that was suggested earlier.

I'm still getting the same results, i've even connected a second LCD to see id thats the issue to no avail.

Here is my current setup and code:

// vi:ts=4
// ----------------------------------------------------------------------------
// HelloWorld - simple demonstration of lcd
// Created by Bill Perry 2016-07-02
// bperrybap@opensource.billsworld.billandterrie.com
//
// This example code is unlicensed and is released into the public domain
// ----------------------------------------------------------------------------
// 
// This sketch is for LCDs that are directly controlled with Arduino pins.
//
// Sketch prints "Hello, World!" on the lcd
//
// See below for configuring the Arduino pins used.
//
// While not all hd44780 use the same pinout, here is the one that most use:
// pin 1 is the pin closest to the edge of the PCB
//  1 - LCD gnd
//  2 - VCC (5v)
//  3 - Vo Contrast Voltage
//  4 - RS Register Select (rs)
//  5 - Read/Write
//  6 - Enable (en)
//  7 - Data 0 (db0) ----
//  8 - Data 1 (db1)     |-------- Not used in 4 bit mode
//  9 - Data 2 (db2)     |
// 10 - Data 3 (db3) ----
// 11 - Data 4 (db4)
// 12 - Data 5 (db5)
// 13 - Data 6 (db6)
// 14 - Data 7 (db7)
// 15 - Backlight Anode (+5v)
// 16 - Backlight Cathode (Gnd)
//
// ----------------------------------------------------------------------------
// LiquidCrystal compability:
// Since hd44780 is LiquidCrystal API compatible, most existing LiquidCrystal
// sketches should work with hd44780 hd44780_pinIO i/o class once the
// includes are changed to use hd44780 and the lcd object constructor is
// changed to use the hd44780_pinIO class.

#include <hd44780.h>
#include <hd44780ioClass/hd44780_pinIO.h> // Arduino pin i/o class header

// declare Arduino pins used for LCD functions
// and the lcd object

// Note: this can be with or without backlight control:

// without backlight control:
// The parameters used by hd44780_pinIO are the same as those used by
// the IDE bundled LiquidCrystal library
// note that ESP8266 based arduinos must use the Dn defines rather than
// raw pin numbers.
#if defined (ARDUINO_ARCH_ESP8266)
const int rs=D8, en=D9, db4=D4, db5=D5, db6=D6, db7=D7; // for esp8266 devices
#else
const int rs=8, en=9, db4=4, db5=5, db6=6, db7=7;       // for all other devices
#endif
hd44780_pinIO lcd(rs, en, db4, db5, db6, db7);

//with backlight control:
// backlight control requires two additional parameters
// - an additional pin to control the backlight
// - backlight active level which tells the library the level
// needed to turn on the backlight.
// note: If the backlight control pin supports PWM, dimming can be done
// using setBacklight(dimvalue);
//
// WARNING: some lcd keypads have a broken backlight circuit
// If you have a lcd keypad, it is recommended that you first run the
// LCDKeypadCheck sketch to verify that the backlight circuitry
// is ok before enabling backlight control.
// However, the hd44780_PinIO class will autodetect the issue and
// work around it in s/w. If the backlight circuitry is broken,
// dimming will not be possible even if the backlight pin supports PWM.
//
#if defined (ARDUINO_ARCH_ESP8266)
//const int rs=D8, en=D9, db4=D4, db5=D5, db6=D6, db7=D7, bl=D10, blLevel=HIGH;
#else
//const int rs=8, en=9, db4=4, db5=5, db6=6, db7=7, bl=10, blLevel=HIGH;
#endif
//hd44780_pinIO lcd(rs, en, db4, db5, db6, db7, bl, blLevel);

// LCD geometry
const int LCD_COLS = 16;
const int LCD_ROWS = 2;

void setup()
{
 // initialize LCD with number of columns and rows: 
 //
 // note:
 // begin() will automatically turn on the backlight if backlight
 // control is specified in the lcd object constructor
 //
 lcd.begin(LCD_COLS, LCD_ROWS);

 // if backlight control was specified, the backlight should be on now

 // Print a message to the LCD
 lcd.print("Hello, World!");
}

void loop() {}/code]

@Paul__B - I changed the ilustrations in my thesolaruniverse.wordpress blog:

Here is my bloody very utmost simple 'hello world' sketch for the 16x2 parallel LCD using the Aduino IDE's <LiquidCrystal.h>

// ==============================
#include <LiquidCrystal.h>

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

void setup() {
lcd.begin (16, 2);
lcd.print ("hello, world!");
}

void loop() {
}

@ JohnK75 - if your (or the above) sketch does not work, connect another 16x2 LCD to your Arduino, or connnect your 16x2 LCD to another Arduino.

Succes

JohnK75:
photoncatcher, I have rewired to your diagram, with and without the 5v to the pot (as per Paul__B's suggestion)and am still getting the same result as before.

Just to mention, it is (almost) never related to problems with actually getting the display to actually work, so not in any way whatsoever related to your present difficulties, but I would like to explain that it is not a matter of trying "with and without the 5v to the pot".

Connecting the pot to 5 V is in fact a stupid blunder made by some early designer quite a long time ago using a diagram in the HD44780 datasheet relating to a test circuit which was never intended for production. It has been quite mindlessly copied from one amateur design to another over that period without any attention to whether or not it is correct or appropriate.

Using a 10k pot and connecting it to the 5 V simply makes it more difficult to adjust the contrast and wastes an amount of current which is in itself, relatively minor and trivial compared to the LED backlight but actually represents a substantial part of the total current drawn by the liquid crystal display itself.

This is not a disputable matter and it is simply not worthwhile to try it any other way. Following my advice will make the task of getting the display to work ever so slightly easier, but only because you will be able to set the contrast conveniently so that the "blocks" in the first row are showing.

Having the "blocks" showing indicates that the display is connected correctly to power and that the contrast is set such that the display when initialised and fed meaningful data would be able to show it but that it is not at that point responding to the lcd.begin(16, 2); initialisation.

photoncatcher:
@Paul__B - I changed the ilustrations in my thesolaruniverse.wordpress blog:

Oops! That is worse!

Didn't notice until I had posted my last comment and looked at it closely!

@ photoncatcher
While you are at it you should fix the other picture.

There are two epoxy blobs on the back of your device. The larger one, on the right, is the HD44780 (or equivalent) controller. The smaller one, on the left, is the HD44100 (or equivalent) auxiliary controller.

Don

photoncatcher:
@Paul__B - I changed the ilustrations in my thesolaruniverse.wordpress blog:

Here is my bloody very utmost simple 'hello world' sketch for the 16x2 parallel LCD using the Aduino IDE's <LiquidCrystal.h>

// ==============================
#include <LiquidCrystal.h>

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

void setup() {
lcd.begin (16, 2);
lcd.print ("hello, world!");
}

void loop() {
}

@ JohnK75 - if your (or the above) sketch does not work, connect another 16x2 LCD to your Arduino, or connnect your 16x2 LCD to another Arduino.

Succes

Thanks once again, I have tried this, but with the pot to gnd not 5v with the same results.

I am now waiting for the amazon man to bring me a new Arduino, breadboard and jumpers, I'll keep this thread updated.

@Paul__B, Floresta and JohnK75.

My first experience ever with Arduinos was with the gear included in the official Arduino Starter Kit (Arduino Starter Kit Multi-language — Arduino Official Store). This kit included a booklet that introduces the ultimate greenhorn I was at that time in the wonderful and colorful world of electronic gadgets. The booklet, "Arduino Projects Book" (second edition; note: the OFFICIAL booklet, with Massimo Banzi in the Advisory board, and reviewed by Tom Igoe) features a project # 11, 'Crystal Ball' that describes how one should connect a 16x2 LCD display to an Arduino: "Place the potentiometer on the breadboard, connecting one end pin to power and the other to ground. The center pin should connect to V0 on the LCD. This will allow you to change the contrast of the screen".
:o

So far so good. Method 1 is pot meter wiper to pin 3 on the LCD display. Remaining pins of the pot meter to 5V and GND. Blessed by the supreme authorities.

Method 2 is pot meter wiper to to pin 3 on the LCD display, one of the remaining pins to GND. See corrected illustration in the project in How to display Arduino sensor data on a ‘classic’ lcd display – thesolaruniverse


updated my illustrations - thanks for your comments):

Method 3. Resistor between pin 3 of the LCD display and GND. Determine experimentally how much resistance you need. In the case of my own LCD the optimal resistance is 470 Ohm. An article on Circuits4you suggests 1k (16×2 LCD interface with Arduino UNO | Circuits4you.com).

Method 4. The software pin resistor solution. Suggested by Somtips (Connect Arduino LCD without Potentiometer Register & I2C - Som Tips): pin 6 of the Arduino to pin 3 of the LCD display.

#include <LiquidCrystal.h>
int Contrast=145;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);  

 void setup()
 {
     analogWrite(6,Contrast);
     lcd.begin(20, 4);
  } 
     void loop()
 { 
   lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("Hello Somnath");
   delay(1000);
   // and so forth
   
 }

This did not work with my Arduino nano- lcd display.

In conclusion: if your lcd display does not work: 1. Check the sketch, 2. Check the wiring, 3. Check all the pins, 4. Check the breadboard, 5. Replace all the wires, 6. Check the pot meter, 7, connect lcd display to another Arduino, 7, connect another lcd display to your Arduino, 8, ask the guys at Arduino Forum, 9, solder everyting firmly together, 10, buy another lcd.

Finally: when you are desperate: remember "if all else fails, read the manual".
.
Ciao, Floris

  • thanks for your comments. This is a great forum.

photoncatcher:
@Paul__B, Floresta and JohnK75.
. . .

#include <LiquidCrystal.h>

int Contrast=145;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
    analogWrite(6,Contrast);
    lcd.begin(20, 4);
  }
    void loop()
{
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Hello Somnath");
  delay(1000);
  // and so forth
 
}




This did not work with my Arduino nano- lcd display. 
. . .

Method 0. Connect pin 3 to GND.

That code won't work well with any microprocessor. Here are some of the reasons.

  • You should display non-changing text in setup(), not in loop().
  • Putting a 'clear' instruction in loop() is a recipe for disaster.

To test an LCD it is best not to aim at a moving target (in this case changing data). Put all the required code in setup() and leave loop() empty.

Also - the three terminal device to which you are referring is not used to meter pots. It is neither a potmeter nor a pot meter, it is a potentiometer. With only two terminals in use as Paul suggests it is wired as a rheostat. True rheostats are constructed differently but that's a different topic.

Finally - It looks like your display has an on-board current limiting resistor (R8) for the backlight. In that case the external 220 ohm resistor is not really necessary.

Don

I just looked at the photos in the zip file in the first post.
The soldering of the header pins to the LCD module is not good.
That is likely the issue.

--- bill

photoncatcher:
So far so good. Method 1 is pot meter wiper to pin 3 on the LCD display. Remaining pins of the pot meter to 5V and GND. Blessed by the supreme authorities.

Who frankly, haven't a clue! :roll_eyes: Merely copying from earlier experimenters who didn't have a clue either.

photoncatcher:
Method 3. Resistor between pin 3 of the LCD display and GND. Determine experimentally how much resistance you need. In the case of my own LCD the optimal resistance is 470 Ohm. An article on Circuits4you suggests 1k (16×2 LCD interface with Arduino UNO | Circuits4you.com).

Generally will work, given the supply voltage is 5.0 V. It means that the optimum contrast voltage is usually about 4.8 V (at room temperature) and reasonably consistent from display to display; presumably all made by one manufacturer (and why would there be more than one anyway?).

photoncatcher:
Method 4. The software pin resistor solution. Suggested by Somtips (Connect Arduino LCD without Potentiometer Register & I2C - Som Tips): pin 6 of the Arduino to pin 3 of the LCD display.

int Contrast=145;

void setup()
{
    analogWrite(6,Contrast);
    lcd.begin(20, 4);
 }



This did not work with my Arduino nano- lcd display.

And you would not expect it to; it is a singularly stupid idea.

It will however work more-or-less if you make Contrast=0; because that will essentially ground pin 3 via the 45 Ohm resistance of the output driver in the ATmega.

analogWrite - PWM - is not an analog voltage, it is a signal switching between 0 and 5 V. The multiplexing to the LCD is also a signal switching between multiple different voltages so the likelihood of the two corresponding in any meaningful manner is pretty low indeed and only as long as the PWM is zero.

photoncatcher:
Ciao, Floris

  • thanks for your comments. This is a great forum.

Indeed it is. :sunglasses:

floresta:
Finally - It looks like your display has an on-board current limiting resistor (R8) for the backlight. In that case the external 220 ohm resistor is not really necessary.

R8 is "101" - 100 Ohms on the standard 1602 display. "510" or 50 Ohms on the 2004 displays, or two 100 Ohms for two LEDs. Apparently there used to be some antique displays lying around somewhere which did require an external resistor.

bperrybap:
I just looked at the photos in the zip file in the first post.

Daring!

Well, we possibly trust a poster who has engaged in serious dialogue on this forum and I could have examined the content safely as I am of course, not using Windoze here but it is a serious point as auto-extracting zip files (and active exploits with other archive formats) are a major vector for ransomware and other viruses.

Windows? I don't use that mess or any other Microsoft product.
Never have other than for a couple of years during the mid 90s when developing NT network drivers.
I've been a *nix guy since the early 80s.

--- bill

Update and closure I hope!

As has already been said, this is a great forum and I really appreciate the help.

The Amazon man delivered a new uno and breadboard, and as I wanted to start from scratch I wired everything as per the manufacturers tutorial (except no connection to 5v on the pot).

Same result, nothing >:(

bperrybap:
I just looked at the photos in the zip file in the first post.
The soldering of the header pins to the LCD module is not good.
That is likely the issue.

--- bill

bill was spot on with this, my eyesight isn't what it was and despite me checking the continuity between the Arduino and the pads on the display, I re-soldered and now it works.

Apologies again for the .zip, the forum had issues with my pics on their own.

Thanks again for everyones help.

For anyone else still struggling, this is the code that worked for me, no backlight with this so viewing angles are a bit narrow, but its a start to prove it works!

Also remember not to connect the pot to 5v.

//www.elegoo.com
//2016.12.9

/*
  LiquidCrystal Library - Hello World

 Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
 library works with all LCD displays that are compatible with the
 Hitachi HD44780 driver. There are many of them out there, and you
 can usually tell them by the 16-pin interface.

 This sketch prints "Hello World!" to the LCD
 and shows the time.

  The circuit:
 * LCD RS pin to digital pin 7
 * LCD Enable pin to digital pin 8
 * LCD D4 pin to digital pin 9
 * LCD D5 pin to digital pin 10
 * LCD D6 pin to digital pin 11
 * LCD D7 pin to digital pin 12
 * LCD R/W pin to ground
 * LCD VSS pin to ground
 * LCD VCC pin to 5V
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)

 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (http://www.ladyada.net)
 example added 9 Jul 2009
 by Tom Igoe
 modified 22 Nov 2010
 by Tom Igoe

 This example code is in the public domain.

 http://www.arduino.cc/en/Tutorial/LiquidCrystal
 */

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

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);
}
/code]

bperrybap:
Windows? I don't use that mess or any other Microsoft product.

I most certainly would not were it not that the software that runs my business is produced by a mob of cowboys who cobble it together using Windoze "Tonka Toys" stuff. The latest bugs are a riot - windows spontaneously switching, often at unpredictable times.

Some years ago (at least 15 years I think) we did try and get a craft group together to do the job properly but the problem was of course that well - we all have a job that generally exceeds 9 to 5 and needed to have something that we could use for at least the minimum requirements of that job in order to actually use it and build on. Over the years, it has obviously become more complex with integration into government prescription and billing systems and the entry threshold is now pretty much impossible.

Just recently had to "migrate" - I was told today that the Health Department people also use that term rather than the mendacious "upgrade" - to Win 10 on 10 of my 11 work PCs; the 11th will be retired shortly when I bite the bullet and move the server function. Now that was fun to be sure! :roll_eyes:

Sad. :astonished: