Tuesday 24 May 2011

LCD Tutorial 3

Display Address, Display cursor, blink and underline


2 Lines & 16 Character - Address

Since we are using 2x16 LCD module. 2 and 16 are lines and characters respectively. Each character has unique address as shown above. Maybe you want to start to start from seventh cursor (0x07) instead of first cursor (0x00). At the bottom line of the command control codes, you would see a lot of A. Well A stands for Address. You need to enter 0x87 after = in the fifth line. Then repeat the displaying codes in the second tutorials:

This time, you are going to learn how to display cursor, blink and underline. It is fairly simple procedure like what you have learned in your previous tutorial. Again you need to look up the command control codes table at fourth row, D, U and B represents display, underline and blink respectively. The binary number would be '1000' or '0x08' in hexadecimal number. Now you need to use the similar code as described above and modify line five by putting 0x08. Compile the software and upload the Hex files in your microcontroller chip and give it a test. Your LCD display should like this:

void main()
{
    // Set 8 bits, Line 2 and 5x7 format
    RW=0;
    RS=0;
    DATA=0x3B;
    ENABLE=1;
    De
lay_Loop(5);
    ENABLE=0;
    // Display position 7th on 1 line
    DATA=0x87;
    ENABLE=1;
    Delay_Loop(5);
    ENABLE=0;

    // Display underline, cursor and blink
     DATA=0x0F;
     ENABLE=1;
     Delay_Loop(5);
     ENABLE=0;
}