This topic is mainly used to set display on/light and cursor settings.
This is not much different from the previous question.
# Include <reg52.h>
# Define uchar unsigned char
# Define uint unsigned int
Uchar code table [] = "Good good study! ";
Uchar code Table1 [] = "day up ^_^! ";
Sbit lcden = P3 ^ 4;
Sbit rs = P3 ^ 5;
Sbit Dula = P2 ^ 6;
Sbit wela = P2 ^ 7;
Uchar num;
Void delay (unsigned char I)
{
Unsigned char J, K;
For (j = I; j> 0; j --)
For (k = 90; k> 0; k --);
}
Void write_com (uchar Com)
{
Rs = 0; // select write command
P0 = com; // send the command to be written to the Data Bus
Delay (5 );
Lcden = 1; // enable a high pulse because the LCD is set to 0 in the initialization function.
Delay (5 );
Lcden = 0; // complete high pulse
}
Void write_data (uchar date)
{
Rs = 1; // write data
P0 = date;
Delay (5 );
Lcden = 1;
Delay (5 );
Lcden = 0;
}
Void Init ()
{
Dula = 0;
Wela = 0;
Lcden = 0;
Write_com (0x38 );
Write_com (0x0c );
Write_com (0x06 );
Write_com (0x01 );
}
Void main ()
{
Init ();
Write_com (0x80 + 0x10); // write the data in the non-display area address of the first line of the LCD, the purpose is to use the screen shifting command to move the LCD screen to the left.
For (num = 0; num <16; num ++)
{
Write_data (Table [num]);
Delay (5 );
}
Write_com (0x80 + 0x40 + 0x10 );
For (num = 0; num <15; num ++)
{
Write_data (Table1 [num]);
Delay (5 );
}
For (num = 0; num <16; num ++)
{
Write_com (0x18); // move the entire screen to the left
Delay (1000 );
}
While (1 );
}
Check the register configuration.