LCD interface

This example is based on a LCD module with the Hitachi HD44780 LCD-controller.You can get these displays in various kinds, from 1 to 4 lines and from 8 to 40 characters per line.
A display with 16 characters per line and 2 lines is used in this example. The display uses a power supply of 5V DC. The LCD controller can accept 8 bit data bytes or 4 bit nibbles. In this example the 4-bit mode is used. There are more to find on the internet. But I wanted to make my own 4-bit LCD interface, to develop my skills in C-programming.
LCD interface

Schematic and build

The interface uses the 4-bit mode of the LCD so you need only one port. Here PORTB is used, but you can use any other port.
See the schematic below.


To make the software code is build with the WINAVR compilier.
The program can be adapted to use another port.  The program can write instructions and data to the LCD controller. There are also functions to control the display and to write text string to the LCD.
LCD interfa

The complete function set:

void LCD_init(void)   // init LCD
void LCD_inst(unsigned char inst)   // writes a instruction to the LCD
void LCDclr(void)   // clear display
void LCDhome(void)   // return home
void LCDoff(void) // LCD off
void LCDon(void)   // LCD on
void LCDcursor(void)  // cursor on
void LCDblink(void)  // blink on
void LCDall(void)   // cursor all on
void LCDline(x)   //go to first line
void LCDline(x)   //go to second line
void LCDgoto (x,y)   // goto position x,y
void LCDtext(data)   //write text to the LCD
void LCDint(data)   //write integer to the LCD
Download the complete code below.
For more detail:  LCD interface

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top