Guys, explain what LCD 1602 means from E=0 to e=1
Author:Ji Jun Time:2021-07-22 09:39 Browse(473)
Before LCD1602 displays characters, you need to input the address of the characters. This is also the reason why you need to add one to each character. In the following code, you will understand how to set the address, how to add one to the address automatically, how to clear the screen, and how to display characters. I hope you can understand it
Before LCD1602 displays characters, it is necessary to input the address of the characters, which is also the reason why one character should be added to the address of each character displayed. In the following code, you will understand how to set the address, how to make the address automatically add one, how to clear the screen, and how to display characters. I hope you can understand it.
sbit LCD_ E=P2^0; // LCD 1602 control set.
sbit LCD_ RW=P2^1; // LCD 1602 control set. sbit LCD_ RS=P2^2; // LCD 1602 control set.
void LCD_ command(unsigned char com).
.
{.
LCD_ E=0;.
LCD_ RW=0;.
LCD_ RS=0;.
P1=com;.
delay_ us(100);.
LCD_ E=1;.
delay_ us(100);.
LCD_ E=0;.
}.
void LCD_ date(unsigned char dat).
{.
LCD_ E=0;.
LCD_ RW=0;.
LCD_ RS=1;.
P1=dat;.
delay_ us(100);.
LCD_ E=1;.
delay_ us(100);.
LCD_ E=0;.
} .
LCD_ command(0x38); // Set the LCD to 16 * 2 display.
set the LCD to 16 * 2 display5 * 7 dot matrix, 8-bit data interface.
LCD_ command(0x0c); // Set LCD display on.
cursor display off.
LCD_ command(0x06); // Add 1 to the address after writing a data.
LCD_ command(0x01); // The display is clear.
LCD_ command(0x80); // The data pointer is set to the first bit of the first line.
LCD_ date('pi');.
LCD_ date('l');.
LCD_ date('e');.
LCD_ date('a');.
LCD_ date('s');.
LCD_ date('e');.
LCD_ date(' ');.
LCD_ date('c');.
LCD_ date('h');.
LCD_ date('e');.
LCD_ date('c');.
LCD_ date('k');.
LCD_ date(' ');.
LCD_ date('t');.
LCD_ date('h');.
LCD_ date('e');.
LCD_ command(0x80+0x40); // The LCD address pointer points to the first position in the second line.
LCD_ date('c');.
LCD_ date('o');.
LCD_ date('n');.
LCD_ date('n');.
LCD_ date('e');.
LCD_ date('c');.
LCD_ date('t');.
LCD_ date('i');.
LCD_ date('o');.
LCD_ date('n');.
LCD_ date('!');.
LCD_ date('!');..
before LCD1602 displays a character, you need to input the address of the character.
this is also the reason why you need to add one to the address of each character displayed. In the following code, you will understand how to set the address, how to automatically add one to the address, how to clear the screen, and how to display characters. I hope you can understand it.
sbit LCD_ E=P2^0; // LCD 1602 control set.
sbit LCD_ RW=P2^1; // LCD 1602 control set.
sbit LCD_ RS=P2^2; // LCD 1602 control set.
void LCD_ command(unsigned char com).
.
{.
LCD_ E=0;.
LCD_ RW=0;.
LCD_ RS=0;.
P1=com;.
delay_ us(100);.
LCD_ E=1;.
delay_ us(100);.
LCD_ E=0;.
}.
void LCD_ date(unsigned char dat).
{.
LCD_ E=0;.
LCD_ RW=0;.
LCD_ RS=1;.
P1=dat;.
delay_ us(100);.
LCD_ E=1;.
delay_ us(100);.
LCD_ E=0;.
} .
LCD_ command(0x38); // Set LCD to 16 * 2 display.
5 * 7 dot matrix, 8-bit data interface.
LCD_ command(0x0c); // Set LCD display on.
cursor display off.
LCD_ command(0x06); // Add 1 to the address after writing a data.
LCD_ command(0x01); // The display is clear.
LCD_ command(0x80); // The data pointer is set to the first bit of the first line.
LCD_ date('pi');.
LCD_ date('l');.
LCD_ date('e');.
LCD_ date('a');.
LCD_ date('s');.
LCD_ date('e');.
LCD_ date(' ');.
LCD_ date('c');.
LCD_ date('h');.
LCD_ date('e');.
LCD_ date('c');.
LCD_ date('k');.
LCD_ date(' ');.
LCD_ date('t');.
LCD_ date('h');.
LCD_ date('e');.
LCD_ command(0x80+0x40); // The LCD address pointer points to the first position in the second line.
LCD_ date('c');.
LCD_ date('o');.
LCD_ date('n');.
LCD_ date('n');.
LCD_ date('e');.
LCD_ date('c');.
LCD_ date('t');.
LCD_ date('i');.
LCD_ date('o');.
LCD_ date('n');.
LCD_ date('!');.
LCD_ date('!');.<
.
it only represents personal opinions.
don't spray if you don't like it, thank you.
.
.
thank you
Hot labels
Related topics