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?
Interfacing JHD404A (40×4) Lcd with 89c51 Microcontroller
40×4 lcd connections with 8051 microcontroller
40×4 lcd with microcontroller code
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