Go Down

Topic: ShiftRegLCD lib (LiquidCrystal 3-wire replacement) (Read 17233 times) previous topic - next topic


Update: Inluded an overview of the functions in its own wikipage, which was long overdue. So far I just used to look at the ShiftRegLCD.cpp if I needed to know what the functions (or methods) were.


thanks for your reply.
the contrast is ok. i can read the first line perfectly. last night i was connecting the display directly (4 bit parallel) with the arduino 0017 demo code, but could'nt get it to display info at all, so it could be that the lcd ids faulty. i will, receive another one this week, so i can check that later.

nice job!
"We're all in this together..."


Feb 21, 2010, 07:31 am Last Edit: Feb 21, 2010, 09:54 am by Du-z Reason: 1
hey guys, this thread is a little old but it has helped me so much, i have gotten all four lines working on my LCD screen but with only 1 problem. whenever i try to set the cursor it prints out two weird characters. any idea why this is.

here a image of it.


could you please edit the previous message so i don't have to stand 10 meters from my screen to see the picture? 640x480 will be enough...
"We're all in this together..."


woops i never preview the image before i posted sorry. it has been substituted with a thumbnail. :)



Could it have anything to do with the datatype you are using to set the position? Although I would think it would cast variable types automatically if that was the case. Also, your LCD shows the text properly, so it basically works. But just in case, can you say something about your circuit? What type of shiftregister, and how long are the wires connecting to it from the arduino? Noise maybe? Maybe the LCD isn't completely HD44780 compatible?

Actually I doubt all of what I'm saying here :P In short; weird!

A question or two: even if the two strange characters show, does it actually change the cursor position? If not, how did you get it to the next line? What if you tried to write ASCII character 13 (CR), and / or ASCII character 10 (LF), will that get you to the next line without any strange output? Just a thought. I have never actually tried this with any LCDs yet.


it must of been something in the code that was grabbing the temperature data, when i tried a simple Hello World on each line it didn't happen.

i was/am using the 3 wire method with a 74LS164N.


Hi To all,

I am N.Nandhakumar from India. I am doing a project as part of my academics. I am doing a Datalogging project using EM-406a GPS and Arduino named "Tran-Duino"

I am also using the Adafruit GPS shield V1.1 and a 2-line JHD162a LCD display.

In the Arduino , pins 10-13 is used for sd card storage, pins 0-4 is used by GPS. I want to display the data the GPS logs into the sd card.

I have found the code for that, but since LCD display requires atleast 6 pins ,and the arduino is left with only 5 pins, I am not able to connect the LCD. If I do so, It just displays junk values  :'( .

Then I googled and I found the arduinoshiftreglcd library and tried it using 74HCT164N IC . But I am getting only the black Blocks in the first line of the display.

I followed the schematic given in this same thread . I am having a Arduino ATMEGA328 made by Bhasha Technologies, India.

I am using Arduino-0017 IDE in Ubuntu 9.10

Now My doubts are,

How to display text?

I can afford to connect the LCD with maximum 5 wires [ since that is the number of wires left in the arduino ] . So, It would be a great help If I get a interface less than that.

I also need help on how to display the text in 2 lines of the display

Please Help me out.

Waiting for your valuable suggestions

Thanks in advance

N.Nandhakumar :)


Sparkfun has several serial LCD's. Here's one:

Only requires +5V, Gnd, and one digital pin.
The art of getting good answers lies in asking good questions.


have you connected the contrast controlling potentiometer to the lcd?


Thanks for the reply Mircho and PaulS .

I am using a variable resistor POT in the schematic .

But even when I tuned it , the black blocks only gets disappeared slowly but I am not able to get any text on it .

I am not able to identify the problem clearly . I have built the schematic using breadboard and also tried by directly soldering the wires to the IC using a IC Base.

In  both the ways I get only the same output - black blocks.

Please give your suggestions. It will be of great help if I build the circuit using the shift register .




You have listed pins 0-4 and 10-13 as being used in your sketch, but you have not said that you are using any of the analog pins.

If you are not using the analog pins for any other purpose, you can use them as digital pins, referred to as numbers 14 (analog input 0) to 19 (analog input 5). You then have 11 pins available for output, not the 5 you think you have.



How are you connecting the LCD/shiftregister? Via two or three wires? As stated, some (me included) had trouble getting the two-wire method to work with a HC family shiftregister. I am not sure why though. I guess the same applies to HCT. You can either try with a LS type shiftregister, or use the three-wire method (unless you are already doing that, in which case I do not know what the issue is).

Maybe if you posted the code related to the LCD it would help, as well as the schematic you use for the LCD.

Also, as TBAr explains, the analog inputs 0 to 5, can be used as digital I/O 14 to 19.

I am also using Ubuntu 9.10 and usually arduino-0017 btw, but I do not think that is the issue.
I have an old HD44780 compatible one-line LCD as well as a 2-line LCD named "JHD202C", which both works fine with the library.

As for using your 2nd line, you must first initialize the display correctly. The functions are explained in the usage page.

#include <ShiftRegLCD.h>
ShiftRegLCD srlcd(Datapin, Clockpin, Enablepin or TWO_WIRE [, Lines [, Font]])

Or, if using three wires, and a 2-line display. Enable will be on pin 8:
#include <ShiftRegLCD.h>
ShiftRegLCD srlcd(12, 13, 8, 2);


Cursor positioning
srlcd.home();  // Set cursor position to zero
srlcd.setCursor(column, row); // Sets cursor position

Remember row begins at row 0 (zero), for the first line. Also column begins at column 0.

Hope this helps.


Hi Folks,

Can anyone tell me if the NTE brand NTE74LS164 is suitable for use with ShiftRegLCD. I'm not sure what the significance of the "N" is in the part number.

For some background?
I've had no luck getting ShiftRegLCD to work using a 74HC164N and, most recently a NTE74LS164. I've tried both 2 wire and 3 wire circuits and checked my wiring so many times that I am seeing it in my sleep. I think I may have blew out the HC and it seems like the LS is the way to go at any rate. My LCD works fine when hooked up parallel and the contrast setting is the same.


Go Up