LCD 1602 via 74HC595

Hi,

I am trying get an LCD 1602 to display text via a74HC595, however I am only getting the 1st column of information.
I am using the liquidcrystal595 library.
Can anyone assist.

Post the code.
Post a schematic of the wiring.
Post photos of the wiring.
Post a link to where you got the library.

Please find attached copy of sketch and source library.

Please see wiring details below:

SR Pin 14 to Arduino Pin 12
SR Pin 12 to Arduinio Pin 11
SR Pin 11 ton Arduino Pin 9
SR Pin 16 to +5v
SR Pin 10 to +5v
SR Pin 8 to GND
SR Pin 13 to GND

LCD Enable to SR Pin 15
LCD D7 to SR Pin 1
LCD D6 to SR Pin 2
LCD D5 to SR Pin 3
LCD D4 to SR Pin 4
LCD RS to SR Pin 7
LCD RW to GND
LCD Cathode to GND
LCD Anode via BC547, 68ohm and 1k resistors to +5v
LCD VSS to GND
LCD VDD to +5v
LCD VO to +5v and GND via 10K Pot

I hope this is enough.

Thanks,

HelloWorld2222.ino (1.55 KB)

LiquidCrystal595.h (3.91 KB)

What Arduino board are you using?

I wish that you would have provided a link to the library. It took me a bit of time to find and install the right one.

Read the how get the most out of this forum sticky to see how to properly post code. Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code in code tags.

I connected up the circuit with a 595, Uno and 16x2 LCD and uploaded your code. I get "hello, world!" on the top line and a count of seconds on the second line. The code and circuit seem to work fine for me.

So, carefully check your wiring.

If you do not find the problem, post a photo of your display. I am not sure what " 1st column of information" means. And post a clear photo of your wiring. Sometimes an extra pair of eyes sees things that are missed.

Your contrast pot is not wired correctly. The correct way to wire the contrast pot is to wire one end of the pot to ground and the wiper to pin 3. The other end of the pot not connected or connected to the wiper. The long standing advice that the pot is wired to ground, Vcc and pin 3 is wrong. It is an error perpetuated over many years that begs correction.

On my displays I just put a 1K resistor from Vo (LCD pin 3) to ground. I find that that give me near perfect contrast.

Please post a link to the library you are using.
The header file posted is not a library. It is just a header file and has no code.

If the library is old and hasn't been maintained then it could have an issue in the write() function where it is not returning the proper status. There were several LCD libraries that had this issue.
This issue was hidden until about IDE version 1.7 or so.
Prior to then the Print class code didn't look at the return value from write() so it didn't matter.
Once the Print class starting looking at the return code, the library would break.
The symptom is that only the first character from the print() call will be output.

I found one library by the name you mentioned that had this problem, but I have no idea which library you are actually using.

The fix is easy if it has the issue. The write() function needs to return the number of characters that were successfully handled.
In most cases this means 1 if it worked and 0 if it failed.

--- bill

On a related note,
I guess I should push forward and add the shift register support code to the hd4780 library.
It is on my list to do, I just haven't gotten around to it.

I am using an adrduino mega. With regards to the lcd, only the h from hello world and the first number of the count is being displayed.

I will see if i can upload the circuit diagram.

I switched the wiring over to a Mega. Wired as in the OP. Got the same result as with Uno. "hello, world!" on top row and seconds counting on second row. The code works for me so it must be wiring or a problem with the display itself.

Really, photos often help us to solve problems.

The library that I found is this one.. Edit, fixed the URL.

pintsize,
You need to tell us which library you are using.
We need to be able to see the code in the library you are using since, IMO, this looks like a s/w issue in the library.

groundFungus:
The code works for me so it must be wiring or a problem with the display itself.

I would say you don't have enough information to come to that conclusion.
It still could be the library issue I mentioned earlier which will only display the first character of whatever is printed.
I would lean to a library issue since the symptoms exhibited exactly match what would be expected if the library has the issue I described.
And if there are h/w issues when using shift register to control an LCD, usually the display is not initlized much less displaying anything.
i.e. IMO, too much is working to be a h/w issue and the symptoms exactly mach the symptoms of a known library issue.

The library that I found is this one.

That link isn't to a library it is a link to a header file.
But the library in the git repository associated with that header file is one of the libraries that I also found.
That library has an issue in the write() code.

inline size_t LiquidCrystal595::write(uint8_t value) {
  send(value, HIGH);
}

It is by shear luck if it works at all since it is not returning anything from the write() function.
As such, the caller will receive a garbage return value.
The Print class code doesn't fully check the return value for a specific value. it only checks that it is non zero. vs equal to 1

What is actually returned to the caller may vary and may depend on a variety of things so it may work in some cases and not in others.
Basically that library has a serious bug and needs to be fixed.

However, we still don't know what library the OP is using as he has not provided us that information.
It may or may not be the library that we found.

--- bill

Thank you. I will upload the library after work.

A link to the library would ok.

--- bill

Please see library attached as requested

LiquidCrystal595-master.zip (8.91 KB)

pintsize:
Please see library attached as requested

That library package is different than one that GroundFungus and I were looking at.
This is an example of why it is so important to post a link to the libraries you are using, especially when those trying to help you are asking for this information.

While the library you are using is different than the library we were looking at, the actual code in both libraries is virtually identical. The only code difference is that the code in the library that GroundFungus and I were looking at turns on LED1 in begin() vs the one in your zip file does not.

So both the library linked to by GroundFungus and the library code you have posted have a significant bug in the write() code as I mentioned. This can cause only the first character of output from print() to show up.

This needs to be fixed.

Where did you get the code you are using?
We have asked for this several times now.
The zip file you attached uses a name that looks like it came from a git repository.
Where did it come from? It would be nice to know to be able to report this bug to the author/maintainer.

You can fix your version of the code easily as I mentioned before.
The print class function write() function returns a size_t
It should return the number of characters successfully written.

For this library it using the single byte version:

size_t  write(uint8_t);

In this library code the write() function is inside an inline wrapper:

inline size_t LiquidCrystal595::write(uint8_t value) {
  send(value, HIGH);
}

send() is void function so it cannot communicate if the i/o succeeded.
However, for this h/w there is now way to know if it succeeded anyway so all you can do in write() is return that it always works.
i.e. you need to fix the inline wrapper to be this:

inline size_t LiquidCrystal595::write(uint8_t value) {
  send(value, HIGH);
  return(1);
}

but again, one more time.
Where did the library code you are using come from?
This is needed so we can notify the author/maintainer of the code that it does not work and needs to fixed.

--- bill

Good chance this is the original author, although I don't perceive he will want to update this as he distributes a zip file (in the article). There seems to be a number of copies around the place as well.

http://www.stephenhobley.com/blog/2011/02/07/controlling-an-lcd-with-just-3-pins/

@OP: Unless you are doing this as a learning exercise, I would suggest the you use LCD backpacks with an I2C interface. These are dirt cheap on eBay (around $1 from the right stores) and a lot more mainstream. I speak from experience. :slightly_frowning_face:

marco_c:
Good chance this is the original author, ....

I think you may be right.
I looked around and have seen many copies of this library floating around out there.
Most of them have the write() function bug.
Some of them appear to be from a copy maintained by a guy named Rowan Simms.
He has a bitbucket repository here:
https://bitbucket.org/rowansimms/arduino-lcd-3pin/src/master/

You can see Rowan made an update to fix the write() issue back on 2016-03-15 to fix the code so that it runs on Arduino 1.6.6 and later.
This is the issue I've been talking about.

Given that there are so many copies of the LiquidCrystal595 library out there floating around and that the original author does not appear to have a known repository set up for it, it does look kind of hopeless to get it fixed.

pintsize,
you will need to fix the write() function in your version of the library code.

At some point I'll probably add shift register support to the hd44780 library.
For now, looking forward, as marco_c said, you may want to consider using one of the inexpensive PCF8574 based i2c backpacks for future projects.
You can pair it with the hd44780 library and have a plug-n-play system that self configures itself.

--- bill

Thanks all,

I could not remember where exactly the library came from, although github does sound familiar. I will have a look I2C interfaces, but in the meantime I will correct the library as suggested.

I think it should work for you once you fix that write() function to return 1

--- bill

This topic was automatically closed after 60 days. New replies are no longer allowed.