Connect LCD to Atmega using 3 wires

After I implemented interfacing LCD to ATmega8 using 2 wires

I decided to make another example but with 3 wires. Using 3 wires makes control much simpler as it is easier to control data flow to shift register. Here I used the same super cheap 74HC164 serial in parallel out register.

avr lcd 3 wires

LCD to shift register is connected in 8-bit mode. LCD strobe pin E is controlled with an Atmega PC2 pin. The register is clocked with PC1, and data is transferred with a PC0 pin. Notice that I used the same data line (PC0) to control the LCD RS pin. RS pin is controlled in this way: after 8 bits are sent to shift register, enable data line by setting ‘1’ (PC0) without clocking and after this LCD E pin is strobed. For more details, take a look at my source code at the end of the article.

If there is any questions, don hesitate to ask.

Source code:3 Wire LCD interface to ATMEGA


  1. there are any problem in using 74LS164 instead 74LS164?


  2. There shouldn’t be any problems with that.

  3. What is the value of R2?

  4. In my actual circuit I have used 10k. This may vary I think from 4.7k as it is Pull-Up resistor only.

  5. Which is the value of r2?

  6. Why the lcd only writes a series of squares instead of the word test?

  7. Why you didn’t use SPI on ATMega ?
    connect SCK,MOSI to 74*164 inputs, D4..D7 and RS to outputs.
    and i.e. SS pin to EN – 3 lines – lcd in 4bit mode 🙂
    it’s much easier to program it (IMHO)

    Best Regards

  8. Using SPI s a good idea. Maybe I will try to simulate this version. Only one disadvantage of such connection is that hardware is tied to SPI pins instead to any MCU pins. I bet programming should be more easy using SPI.

  9. can just use any LCD or must be the one you are using?

  10. Any standard alphanumeric LCD based on HD44780 controller.

  11. I’m need PB3, PB5, PD5 to connect LCD. Help me.

  12. Why my lcd write UESU! instead of TEST!.I use od-dm1601b,tks.

  13. Do you use standard LCD? Are all connections made properly? Because this circuit should work properly – tested myself.

  14. hey kindly help me
    i have atmega 8 and displaytech 16*2 lcd ……i want to display some text when the ir sensor connected to its adc port is to go for it

  15. Hi,

    Does the shift register have to be controlled by the adc pins on the atmega or can another port be used?


  16. You can use any I/O pins for this. Of course you need to do changes in software definitions.


  18. Can you make a new design to use at graphic lcds? Or can you describe it, i can try it by myself. (like 128×64 dotmatrix).

  19. With graphical LCD there would be more mess as there are additional CS[1..2] control pins. So I would think about at least five wires needed. If this would be practical to do this I don’t know. And of course output speed – shift register would take at least 8 times more clock cycles to output one pixel. For slow applications this is OK, but for time critical – not. In such case it would be better to take additional cheap MCU dedicated to GLCD.

  20. Thanks for sharing this code and schematics. It work really good. This is indispensable for tinny MCUs.

  21. Can u mail me the hex file for atmega32 programming for LCD display


Leave a Reply