51 MCU-LCD 1602

Publisher:静雅心灵Latest update time:2015-04-09 Source: cechina Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Liquid crystal is a polymer material. The main principle of liquid crystal display is that electric current stimulates liquid crystal molecules to produce points, lines, and surfaces and cooperates with the back light tube to form a picture. For the sake of simplicity, all kinds of liquid crystal displays are directly called liquid crystal. Various types of liquid crystals are usually named according to the number of rows of displayed characters or the number of rows and columns of liquid crystal dot matrix. For example: 1602 means that 16 characters are displayed per line, and a total of two lines are displayed; similar names include 0801, 0802, 1601, etc. This type of liquid crystal is usually a character liquid crystal, that is, it can only display ASCII code characters, such as numbers, uppercase and lowercase letters, various symbols, etc. 12232 liquid crystal belongs to graphic liquid crystal, which means that the liquid crystal consists of 122 columns and 32 rows. Liquid crystal is small in size, low in power consumption, and simple in display operation, but it has a fatal weakness, and its operating temperature range is very narrow.  
 
Initial setup:  

   


   

RAM address map:  
  
Write operation timing:     
  To achieve two-line display, slide from left to right.
 
#include  
#define uchar unsigned char 
#define uint unsigned int 
 
sbit RS = P1^0; 
sbit RW = P1^1; 
sbit E = P1^2; 
uint i; 
uchar code table[] = "I LOVE MCU!"; 
uchar code table1[]="WWW.TXMCU.COM";  
 
void delay(uint t){ 
    int i,j; 
    for(i = 0; i < t; i++) 
        for(j = 200; j > 0; j--)
            ; 
 
void lcd_com(uchar s){ 
    RS = 0; //Low level, write instruction
    P2 = s; //Transfer data
    delay(14); //Look at the timing diagram, the data needs to be stable for a while 
    E = 1; //Give a high pulse to send a command
    delay(14); //As shown in the figure, the high pulse is delayed for a period of time to ensure that the command is sent
    E = 0; //Send is finished, E is set to low level
 
void lcd_data(uchar s){ 
    RS = 1; 
    P2 = s; 
    delay(14); 
    E = 1; 
    delay(14); 
    E = 0; 
 
void init(){ 
    RS = 1; //First send command, at the initial moment RS is high, E and RW are low 
    E = 0; 
    RW = 0; 
    lcd_com(0x38); //Set to 16*2 display, 5*7 dot matrix, 8-bit data interface
    lcd_com(0x0f); //Turn on the display, display the cursor, and the cursor flashes
    lcd_com(0x06); //Address pointer plus one after reading or writing a character
    lcd_com(0x01); 
    lcd_com(0x80+0x10); //The display screen corresponds to a RAM, and there is another RAM outside the screen
    for(i = 0; i < 11; i++){ //Set the address to the off-screen RAM to achieve the scrolling effect
        RS = 0; 
        lcd_data(table[ i]); 
        delay(40); 
    } 
    lcd_com(0x80+0x50);    
    for(i = 0; i < 13; i++){ 
        RS = 0; 
        lcd_data(table1[ i]); 
        delay(40); 
    }
        for(i = 0; i < 13; i++){
                lcd_com(0x18); //0x18, move the display to the left, and the cursor moves with it
                delay(200);
        } 
 
void main(){ 
    init(); 
    while(1); 
}
 
Reference address:51 MCU-LCD 1602

Previous article:51 MCU-Serial Port
Next article:51 single chip microcomputer - temperature sensor DS18B20

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号