16x2 LCD only showing white squares

I know this has been raised before, and belive me I have read many posts about this problem, but non have worked or not applicable to my setup.

I am using a arduino Nano for a range measure and digital spirit level project.

I am also using 2 full size? breadboards fastend side by side.

I have checked that LCD works by connecting it up to a Arduino Uno on another breadboard and uploading the Hello World code, which the LCD displays fine.

I then moved the lcd screen back onto the double breadboard and used the exact same wiring configuration as it was with the arduino, but there was no change . The LCD screen was still blank.

I found that when I was using a USB port to power up the Nano and other items on the board, the lcd screen was blank. After quite sometime of trying to find out why , I measured some of the supposedly 5v voltages etc. The lcd 5v pin was only showing around 3.8v to 4.3V. The Nano 5v pin was also only showing around 4.7v.

I then used a 5v power supply plug and then there was just 1 row of white squares on the lcd screen. I then tried a 8.5v battery supply and that bought up 2 rows of white squares against just 5v.

The code below is only a part of the full 257 lines, but should be enough. I can only attch 2 pictures as the size of all of them exceeds 2mb

/*
  DIY Digital Range Measurer and Spirit Level
  by Dejan Nedelkovski,
  www.HowToMechatronics.com
*/
#include<Wire.h> // I2C communication library
#include <LiquidCrystal.h> // includes the LiquidCrystal Library
LiquidCrystal lcd(7, 6, 5, 4, 3, 2); // Creates an LCD object. Parameters: (rs, enable, d4, d5, d6, d7)
const int MPU = 0x68; // I2C address of the MPU6050 accelerometer
#define trigPin 8
#define echoPin 9
#define selectButton 10
int16_t AcX, AcY, AcZ;
long duration;
float distance;
int program = 0;
float d = 0;
float d1 = 0;
float d2 = 0;
float area = 0;
int axis = 0;
int angle = 0;
int unitSelect = 0;
String unit = "cm";
void setup() {
  // Initialize interface to the MPU6050
  Wire.begin();
  Wire.beginTransmission(MPU);
  Wire.write(0x6B);
  Wire.write(0);
  Wire.endTransmission(true);
  lcd.begin(16, 2); // Initializes the interface to the LCD screen
  
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(selectButton, INPUT_PULLUP);
}
void loop() {
  switch (program) {  // Switch between different programs
    case 0:  // Select unit of measurement
      lcd.setCursor(0, 0); // Sets the location at which subsequent text written to the LCD will be displayed
      lcd.print("Select Unit: ");
      lcd.setCursor(13, 0);
      lcd.print(unit);
      lcd.print("  ");
      delay(10);
      // If button is pressed - change unit
      if (digitalRead(selectButton) == 0) {
        if (unitSelect == 0) {
          unit = "in";
          unitSelect = 1;
        }
        else if (unitSelect == 1) {
          unit = "m";
          unitSelect = 2;
        }
        else if (unitSelect == 2) {
          unit = "ft";
          unitSelect = 3;
        }
        else if (unitSelect == 3) {
          unit = "cm";
          unitSelect = 0;
        }
        // If button is held longer then half a second - change program
        delay(500);
        if (digitalRead(selectButton) == 0) {
          program = 1;
          lcd.clear();
          delay(500);
        }
      }
      break;
      
    case 1:   // Distance measuring program
      distance = getDistance(); // Distance to the nearest object
      lcd.setCursor(0, 0);
      lcd.print("Dist: ");
      lcd.print(distance); // Prints the distance value from the sensor
      lcd.print("    ");
      lcd.setCursor(14, 0);
      lcd.print(unit);
      delay(10);
      lcd.setCursor(0, 1);
      lcd.print("d:");
      lcd.setCursor(8, 1);
      lcd.print("d:");
      delay(200);
      // Save distance 1
      if (digitalRead(selectButton) == 0) {
        if (d == 0) {
          lcd.setCursor(0, 1);
          lcd.print("d:     ");
          lcd.setCursor(2, 1);
          lcd.print(distance);
          d = 1;
          delay(100);
        }
        // Save distance 2
        else if (d == 1) {
          lcd.setCursor(8, 1);
          lcd.print("d:     ");
          lcd.setCursor(10, 1);
          lcd.print(distance);
          d = 0;
          delay(100);
        }
        // If button is held longer then half sencond change program
        delay(500);
        if (digitalRead(selectButton) == 0) {
          program = 2;
          d = 0;
          lcd.clear();
          delay(500);
        }
      }
      break;

avalon66:
. . .
I have checked that LCD works by connecting it up to a Arduino Uno on another breadboard and uploading the Hello World code, which the LCD displays fine.

I then moved the lcd screen back onto the double breadboard and used the exact same wiring configuration as it was with the arduino, but there was no change . The LCD screen was still blank.
. . .

Have you tried it on the double breadboard, without all the wires going to the other stuff, and with the Hello World code?

ALSO: As you should have noticed from reading previous posts on the subject, we need a photo that allows us to unambiguously follow each wire from one end to the other.

Don

I've tried it on the double breadboard, and disconnected any wires which wasn't needed.

Yes I do realise you would need a picture,and I thought that 2 I did upload would be ok, but I see now that they are not.

Anyway in this attached picture, there is a yellow wire going to the centre pin of the 10k pot. The white and green which are under the yellow wire have been disconnected.All 3 ground wires are zig zag black wires, and the resistor is a 220ohm connected from pin A on the LCD screen to the positive rail.

The wires plugged into the board next to the Nano, from left to right are: Green, Blue, Yellow, 2 Orange, and 1 Red.

The attached picture is a bit fuzzy but that looks like a Comet G-3 antenna on your roof. I know, I have too much time on my hands.

Don

I hope this picture is better for you. When I said there was 2 red wires, 1 of them was replaced by the 220ohm resistor, so there is only 1 red wire.

Also I have removed the 10k pot for now, as I was told by the author of the code to use a voltage devider which have already done.

avalon66:
I hope this picture is better for you. When I said there was 2 red wires, 1 of them was replaced by the 220ohm resistor, so there is only 1 red wire.

It's not any better since it is impossible to discern one twisted orange data wire from another.

Also I have removed the 10k pot for now, as I was told by the author of the code to use a voltage devider which have already done.

The author is incorrect. You can, however effectively replace the potentiometer with a variable resistor (rheostat) by simply removing the connection between V+ and the upper end of the pot. If you want to go with resistors you don't need a voltage divider, one resistor (start with 1k) between pin 3 and GND will do. A zero ohm resistor (a wire) will usually give usable results.

I think it's time for you to disconnect everything and start over with my generic technique that I have presented many times before:

(1) If the module has a backlight then get it working properly. This involves only pins 15 and 16 on most LCD modules. Make sure to use a current limiting resistor if there is none on the LCD module.

(2) Get the power and contrast working properly. This involves only pins 1, 2, and 3 on most LCD modules. You should be able to just barely see blocks on one row of a two row display and on two rows of a four row display.

NOTE: The Arduino has not been used yet, except as a possible source for the power needed for the first two steps. Do not try to go any further until this is working. If you don't see the blocks then no amount of program code will help.

(3) Connect the LCD R/W pin (pin 5) to GND.

(4) Connect the six control and data wires between your LCD module and your Arduino. Make sure that your wiring matches the numbers in the descriptor (or vice versa).

//LiquidCrystal lcd(RS, E, D4, D5, D6, D7);
  LiquidCrystal lcd( 7, 8,  9, 10, 11, 12);      // put your pin numbers here

(5) Upload your sketch and it should work.

For troubleshooting a 'static' sketch, one that displays a simple message or two and then stops is recommended. All of your code should be in setup(), and loop() should be empty between the brackets.

#include <LiquidCrystal.h>

//LiquidCrystal lcd(RS, E, D4, D5, D6, D7);
  LiquidCrystal lcd( 7, 8,  9, 10, 11, 12);      // put your pin numbers here

void setup()
  {
  lcd.begin(16, 2);                              // put your LCD parameters here
  lcd.print("hello, world!");
  lcd.setCursor(0,1);
  lcd.print("it works!");
  }

void loop()
  {
  }

EDIT: I forgot to mention that those jumpers that you are using for several of your connections sometimes cause trouble. I would verify that they are good or replace them with plain wire.

Don

Ok, sorry about the quality of the pictures, but they looked ok on my phone and my PC. I've taken another one with the wires untangled.

The jumper wires are supposed to be Dupont ones, as I was fed up of using the cheapo ones. I do have some single solid core wire jumpers but not in as many colours.

I now havew the backlight and display working where I can barely see a row of squares with a 1k resistor to ground from pin 3.

Regarding this part: (4) Connect the six control and data wires between your LCD module and your Arduino. Make sure that your wiring matches the numbers in the descriptor (or vice versa).

//LiquidCrystal lcd(RS, E, D4, D5, D6, D7);
LiquidCrystal lcd( 7, 8, 9, 10, 11, 12); // put your pin numbers here

Do I then connect the wires from the lcd to the correct pins on the Arduino Nano.

Do I then connect the wires from the lcd to the correct pins on the Arduino Nano.

There are no 'correct' pins. You can use any available I/O pin for any of the LCD signals. You inform the library which ones you have chosen to use by means of the numbers that you put between the parentheses in the 'constructor'. The library expects the pin numbers to appear in the order shown in the comment.

From the previous information you should be able to understand why we need to see both a photo of the setup as well as a copy of the code in order to verify the wiring.

It is extremely difficult to determine which wires go to which pins in your photograph. The picture is taken at a poor angle and it is out of focus. You really need some combination of a better phone, a real camera, and more light.

Take the whole works outside and shoot straight down from as far away as you can get while still zooming in to give a reasonable sized image. Close-up shots introduce enough parallax to make it difficult to identify pin connections.

Don

I used solid single wire for all but 1 of the connections, then took the board outside into daylight and took a picture from about 18 inches away,and after editing it, uploaded it

Anyway, I am pleased to say that is acually displays text now, so it was down to the may stranded jumper wires.

Out of interest, because I plugged the LCD screen direct into the board, are there any jumper wires which can be pluuged onto the pins of the lcd. The wires I have, and some are supposed to be Depont ones , slip off as they can't be pushed on to make a tight fit.

Thanks for your help.

That's a usable photograph - remember the technique you used so you can do it again the next time you have a problem.

It looks like the protective film is still on the display. Your text may be a little brighter/clearer after you remove it.

My cheap oriental female 'Dupont' connectors seem to grip the pins on my displays and other devices. Maybe the header pins on your LCD are thinner than normal.

You could just relegate this display for use on a breadboard and get another one to actually use in a project. Then you could solder wires directly to that second display.

Don

I do have anothe lcd display screen, but as it has an I2C board on the back, the pins for the lcd are on the front, and look ugly on a finished project.

Yes, I may well solder the jumper wires direct to the pins , when it is all finished etc The 'Dupont' female end fits ok on about 2 or 3 of the pins, but on the rest of them, the female end just falls off.

Healthy Dupont females fit nicely on the 0.040" square header pins.

If you push them onto fatter square or round pins the connector will be damaged.
Dupont cables are cheap. Buy some replacements. Be more gentle in the future.

You might be able to dismantle the Dupont and re-form the connector. It will never be as good as a nice fresh virgin female.

David.

I found a hack of sorts which can make the female end tighter, and it was just remove the black plastic housing, and then push down of 2 bendy parts.These are at the top looking at you where the open bit is on the housing. Oh and there is no need for soldering either, which a pluys point for me, as my soldering is garbage now. I used to be able to solder years ago, when I made my own circuit boards for Ham Radio stuff. But that was many years ago now.

I've just done enough now to lift the lcd screen off the board so that I can place it where I want now,

IMG_20190104_120451_HDR.jpg
Upside down! That is a bit dizzying!


david_prentice:
It will never be as good as a nice fresh virgin female.

Wouldn't want to take that one out of context!

avalon66:
I found a hack of sorts which can make the female end tighter, and it was just remove the black plastic housing, and then push down of 2 bendy parts. These are at the top looking at you where the open bit is on the housing.

Well, of course we knew that all along - it is fairly obvious. To remove the housing, you need to carefully lift the plastic tab with a fingernail, screwdriver or knife just enough to slip it off and no more, otherwise it breaks and is unusable. You will want to buy some bulk packs of the housings - generally not the single housings, but two-, three-, four- and five pin, possibly two-by-three to match the programming headers on the Arduinos. Carefully removing the single housings and using the multiple housing makes it easy to swap commonly used modules.

avalon66:
Oh and there is no need for soldering either, which a plus point for me, as my soldering is garbage now. I used to be able to solder years ago, when I made my own circuit boards for Ham Radio stuff. But that was many years ago now.

All that said, you absolutely need to re-skill. "Dupont" jumpers and breadboards are strictly for play. The only situation in which I would be using them in a "finished product" (which is to say, for my own application) is as a convenience to plug in a display module.

avalon66:
I do have anothe lcd display screen, but as it has an I2C board on the back, the pins for the LCD are on the front, and look ugly on a finished project.

I don't follow that at all. With an I2C backpack, the pins are all between the LCD and backpack.

The problem is that the interface pins are often mounted inappropriately pointing out from the end of the display, this is a major design foul-up. In some versions they may be de-soldered and pointed back along the backpack, otherwise you just need to "suck it up" or de-solder and solder your wires direct.

(Alternative - clip off the pins where they bend and solder to the stumps! :astonished: It may be possible just to straighten the pins out.)

I don't know why the picture is upside down , as it is the right way up on my PC. Gremlins possibly!

Thanks for the information about headers , and I am a bit wary what I buy because I want the female connector of the jumper wire to be a good tight fit.

I do have some headers whch have long pins 1 side and short, too short, on the other side. I have tried some jumper wireson them and they are very slack, and fall off, which is no good.

I know there are hundreds of the headers on ebay, and Amazon, so it's a bit of a minefield for me just now.

Go on. Most are square 0.040. i.e. the size used by Dupont shells and connectors.

Typical strips are designed for through-hole soldering to a pcb. Leaving a male or female ready to accommodate the appropriate jumper cable.

Have you never looked at Uno header sockets and mating shields?

Extra long male header strip is used on Nucleo boards. This means you can connect Duponts to both sides of the pcb.

You can buy ready made cables mounted in shells or ready crimped wires with empty shells. Useful for making custom jumper cables with the correct shells.

Individual jumper wires are prone to work loose if you have abused them. A group of wires in a multi-pin shell is very robust.

David.