Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering

Interfacing JHD404A (40×4) lcd with Microcontroller

By EG Projects

This post covers how to interface JHD404A 40×4 lcd with microcontroller (89c51, Pic16f877, Arduino etc). JHD404A is a 40×4 Character lcd. 40×4 means it has 40 coulombs and 4 rows. On each row of lcd we can display 40 characters/numbers etc. Total characters which we can display on 40×4 lcd is equal to (40×4=160) 160.
Like all other character lcd’s JHD404A also has a controller in it which controls its internal functions. 40×4 contains HD44780 lcd controller by hitachi in it. Which means same commands are used to initialize 40×4 lcd that are used to initialize 8×1, 16×1, 16×2 ,20×2 character lcd’s. The only difference between JHD404A and his siblings when compared is, it has two enable pins (en1 & en2). This is because a single HD44780 controller can handle up to 80 characters. To handle 160 characters we need an extra HD44780 controller. ​

Why two enable ports?

Consider a 40×1 or 40×2 lcd they have one enable (en) pin. In contrary to 40×1 and 40×2, 40×4 lcd has two enable (en1 & en2) pins. Actually 40×4 is comprised of two 40×2 lcd’s stacked on each other. We have to initialize 40×4 lcd two times. One initializing is using en1 pin and second is using en2 pin. We have to initialize both HD44780 controllers. First two rows of 40×4 lcd are initialized using en1 pin and then third fourth rows are initialized using en2 pin.
JHD404A (40x4) Lcd pinout

JHD404A (40×4) Lcd pinout

Some tutorials which might help you if you are new and don’t know much about character lcd’s and their working. These tutorials will help you in understanding this post.

  • How character Lcd’s work.
  • Character lcd’s pinout and commands.
I made a PLC(programmable logical controller) in which i used 40×4 lcd to show input and output status. You can also build yours just take a look at it its not a hard task.

  • DIY PLC using Pic microcontroller and 40×4 lcd

Interfacing JHD404A (40×4) Lcd with 89c51 Microcontroller

Interfacing 40×4 lcd with 8051 series microcontrollers is not a hard task. If you have already done interfacing of any other character lcd with 8051 microcontrollers you can easily interface 40×4 lcd with 89c51. I made a simple project the circuit diagram is below.
Interfacing JHD404A with 89c51 microcontroller

Interfacing JHD404A with 89c51 microcontroller

40×4 lcd connections with 8051 microcontroller

Data pins of 40×4 lcd are connected to Port-1 of 89c51 microcontroller. R/W(Read/Write) pin of Lcd is connected to Port-3 Pin#0 of 89c51 microcontroller. En1 is connected to Port-3 pin#1. Rs(Register Select) is connected to Port-3 Pin#2. Vss is grounded. On vdd +5v is applied. En2 is connected to Port-3 Pin#3. Vo is connected to output of variable resistor(Potentiometer). Clock source to microcontroller is provided by external 11.0592MHz crystal.

40×4 lcd with microcontroller code

Code is written in c language. Keil uvision 4 ide is used for writing and compiling code. Hex translation of binary code is also done with keil uvision 4. First header file reg52.h is included in the project. This header file is necessary to be included in every project whose coded is going to be written and compile in keil u vision 4. Next some individual pins of ports are initialized. These pins are going to be used in the project with the names with which they are initialized.

Functions used in the code with description.
delay()               Used to generate some delay.
lcdcmd1()          Used to send commands to first HD44780 Controller
lcdcmd2()          Used to send commands to Second HD44780 Controller
display1()          Used to display data using first HD44780 Controller
display2()          Used to display data using second HD44780 Controller
lcdint1()             Initializes first HD44780 Controller OR first two lines of 40×4 lcd
lcdint2()             Initializes second HD44780 Controller OR third and fourth lines of 40×4 lcd

Microcontroller programming part

In the main() function i first initialized the string that i am going to display on 40×4 lcd. The string is “Its 40×4 Lcd microcontroller-project.com”. This string is displayed on all the four lines of lcd. After the string initialization i initialized the ports Port-1 and Port-3 as Output ports. Then i called on the lcdint1 and 2 functions to initialize the lcd. After this i started displaying string on all the four lines of lcd. while(1) loop is continuously displaying the text on lcd.

Watch the project video Here..

Post by Microcontroller Projects.
Download the project code, folder includes the full keil uvision 4 project files and hex code. Please give us your feed back on the project.
JHD404A with 89c51 Microcontroller(Download)


Filed Under: Microcontroller Projects, PIC Microcontroller

 

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


Featured Tutorials

  • Designing Gate Driver Circuit and Switching Mechanism for Modified Sine Wave Inverter – (Part 9/17)
  • Completing Modified Sine Wave Inverter Design with Full Bridge Circuit and Step Up Transformer – (Part 10/17)
  • Designing an Offline UPS – Part (12 /17)
  • How to reduce Switching Time of a Relay – (Part 15/17)
  • Testing MOSFET – (Part 16/17)
  • Driving High Side MOSFET using Bootstrap Circuitry – (Part 17/17)

Stay Up To Date

Newsletter Signup

Sign up and receive our weekly newsletter for latest Tech articles, Electronics Projects, Tutorial series and other insightful tech content.

EE Training Center Classrooms

EE Classrooms

Recent Articles

  • Renesas to demonstrate first working silicon based on the Arm Cortex-M85 processor
  • STMicroelectronics releases first automotive IMU with embedded machine learning
  • Infineon offers DC-DC controller for full LED headlamps without a microcontroller
  • Vishay launches new high-precision, thin-film wraparound chip resistor
  • STMicroelectronics’ common-mode filters ensure signal integrity in serial interfaces

Most Popular

5G 555 timer circuit 8051 ai Arduino atmega16 automotive avr dc motor display Electronic Part Electronic Parts Fujitsu ic infineontechnologies integratedcircuit Intel IoT ir lcd ldr led maximintegratedproducts microchip microchiptechnology Microchip Technology microcontroller microcontrollers mosfet motor powermanagement Raspberry Pi remote renesaselectronics renesaselectronicscorporation Research samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • Help with Verilog replicate operator
  • Some question on simple FM transmitter
  • Resistor across crystal for biasing the internal op-amp
  • What is a printed circuit board assembly
  • Level shifter for differential oscillator

RSS Electro-Tech-Online.com Discussions

  • Background of Members Here
  • software PWM
  • Audio equalizer
  • SPI Questions
  • Dog Scarer
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering