1602 screen shifting

Source: Internet
Author: User

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.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.