Let us see how to print on the second line of 16*2 using 8051.
Prerequisite: Knowledge about lcdcmd() and lcddata() functions.
Circuit diagram.
Here is the DDRAM address of 16*2 LCD
For 16*2 LCD
ROW1 : 0x80 0x81 0x82 0x83 0x84 ...... 0x8F
ROW2 : 0XC0 0XC1 0XC2 0XC3 0xC4......0xCF
The Display data RAM is the set of addresses where the cursor moves. The data will be written on the position where cursor is. The cursor position(address) can be changed by sending various commands to LCD. For ex: lcdcmd(0x80+02) means Cursor points to 1st row, 3rd column.
Suppose the data is "welcome". On executing 0x82 command,the cursor points to the 1st row, 3rd column. If we start sending data to the LCD. 'w' will be printed on the third position. By default, the address will be incremented for new alphabet. Hence 'welcome' will occupy 03 to 09 address in the above figure.
To use second row, first column of the 16*2 LCD. We should point the cursor to that position. This can be done by using lcdcmd(0x80+0x40) .To use second row, second column(0x80+0x41) and so on. After pointing the cursor to that position. We can write the respective data using lcddata() function.
Using these basic commands, we can print the data on second line of 16*2 LCD.
Many animations can be done by playing with the addresses of DDRAM. Here is a simple demonstration!
Here in the second row, we started printing values from (0x80+0x4D) address and decremented the initial address till the whole array is print. If anyone needs the code and simulation, please use the comment box :).
No comments:
Post a Comment