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.
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.
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.
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.
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..
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.
Filed Under: Microcontroller Projects, PIC Microcontroller
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.