This is a simple project on how to display/print your name on 16×2 LCD using 8051(89c51) microcontroller. Character LCDs come in many packages 16x2, 8x1, 16x1, 8x2. All LCDs actually perform the same function, displaying the data we send to them. Displaying data on 16×2 LCD is not an easy task, but it is not that difficult either. You must first be familiar with the pinout and working of the 16×2 LCD, its internal structure, registers and LCD controller.
I recommend you do this tutorial. It contains all the information about the 16×2 lcd. Its pinout and the functions associated with each pin. The most important LCD pins, rs(register select), rw(read write), and en(enable), are also discussed. Commands used to initialize the lcd and many others are provided in it. Character generation in a 5×8 matrix is also highlighted.
I recommend you do this tutorial. It contains all the information about the 16×2 lcd. Its pinout and the functions associated with each pin. The most important LCD pins, rs(register select), rw(read write), and en(enable), are also discussed. Commands used to initialize the lcd and many others are provided in it. Character generation in a 5×8 matrix is also highlighted.
- 16×2 LCD pinout and operation.
Display Your Name on LCD – Project Circuit Diagram
- Connect port 2 of 8051 microcontroller with 8 data pins of 16×2 LCD. Connect the DB0 pin of the 16×2 LCD to pin 0 of port 2, then DB1 to pin 1, and so on.
- Connect the rs (register select) pin of the 16×2 LCD to port 3, pin 5.
- Connect the rw (read and write) pin of the 16×2 LCD with port 3, pin 6.
- Connect the EN (enable) pin of the LCD to pin 7 of port 3.
- Apply 5 volts to pins 40 (vcc) and 31 (EA) of the 8051 microcontroller (89c51).
- Use microcontroller pin 9 as reset pin. Attach a button to it whenever you want to reset your program, press the button.
- Grounding pin 20.
- Use 11.0592 MHz crystal with two 33 pF capacitors in parallel to pins 18 and 19 of the 8051 microcontroller.
The circuit diagram of the project is given below.
16×2 LCD with 8051 microcontroller – Displaying name on LCD
Displaying name on LCD – Project code
The project code is very easy to understand. I am using keil uvision 4 ide to write and compile code and generate hex file for 8051 microcontroller. First I included reg51.h header file in code. This header file is required if you are using keil software for 8051 microcontroller code and hex file generation. The header file contains the necessary settings of the 8051 microcontroller. Next, three individual bits of port 3 are declared. These bits are stated to be used with 16x2 LCD to switch its rs, rw and en pins when needed. Then a simple delay loop is created to provide the necessary delays where needed in our program code. Next, a command function is created, which performs the function of selecting the 16×2 LCD command register and performing the task associated with each command. Then lcd data function is selecting data record from 16×2 LCD and prints the data on LCD which we input into it. LCD The main function is to initialize the LCD in 16×2 mode with the cursor blinking and the display on. The rest of all the things in the main function are characters that we want to print on our LCD.
Displaying name on LCD – Project Output
The output on the 16×2 LCD is “ !!!WE LOVE IT!!! ” on the first line of the LCD and “ PAKISTAN ” on the second line of the LCD. You can also change the code as per your need. If you want to print your name just put it in LCD data function instead of “ !!!WE LOVE IT!!! PAKISTAN “.
Related Projects
- Moving text display on 16×2 LCD with 8051 microcontroller
- Generating custom characters on 16×2 LCD with 89c51 microcontroller
Download the project code written in keil u vison 4 ide and send us your feedback on the project.
Download code/files