1602 LCD display

Source: Internet
Author: User


Liquid Crystal has 1 or 2 ends as the power supply, 15, 16 for the back light source; to prevent the Direct Addition of 5 V voltage burned back light, 15 pin a 10 euro resistance for throttling.

The LCD 3 end is the LCD contrast adjusting end, and uses a 10 k euro potentiometer to adjust the LCD contrast,

The four ends of the liquid crystal are the data writing/reading data selection ends of the liquid crystal controller, connected to the p3.5 Port

The LCD 5 is the read/write selection end. Because we do not read any data from the LCD, we only write commands and data to it. Therefore, this end is always in the write state, that is, always grounded.

In order to enable the signal, the liquid crystal 6 is a required signal during operation and is connected to the p3.4 port of the single chip microcomputer.


Write Operation Sequence

(1) Use rs to determine whether to write data or commands. Writing Commands include making the LCD display of the cursor/do not show, the cursor flashes/does not flash, the need/do not need to move the screen, where the LCD is displayed, and so on.

(2) The read/write control end is set to the write mode, that is, the Low Level

(3) deliver data or commands to the Data Cable

(4) send data to the LCD controller with a high pulse to complete the write operation.


I wrote a program.

# 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 );
For (num = 0; num <16; num ++)
{
Write_data (Table [num]);
Delay (5 );
}
Write_com (0x80 + 0x40 );
For (num = 0; num <15; num ++)
{
Write_data (Table1 [num]);
Delay (5 );
}
While (1 );
}

Here we can write some simple time series.

Understand the Sequence Chart


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.