Current location - Education and Training Encyclopedia - Graduation thesis - 12864 paper
12864 paper
# include & ltreg 5 1 . h & gt;

# include & ltintrins.h & gt

# include & ltstdio.h & gt

# Define uchar unsigned characters

# define first _ add r0// Defines the display starting position of characters/Chinese characters.

sbit lcd_rs=p2^2;

sbit lcd_rw=p2^3;

sbit lcd_e=p2^4;

sbit pcb=p2^5;

uchar i,j;

Invalid delay (ms)

{

When (ms)

{

for(j = 0; j & lt 120; j++);

}

}

Bit lcd_busy ()

{bit result;

LCD _ RS = 0;

LCD _ RW = 1;

LCD _ E = 1;

Result = (bit) (P0 & amp0x80);

LCD _ E = 0;

Return the result;

}

Invalid lcd_wcmd(uchar cmd)

{

while(LCD _ busy());

LCD _ RS = 0;

LCD _ RW = 0;

P0 = cmd

LCD _ E = 1;

LCD _ E = 0;

}

void lcd_wdata(uchar dat)

{

while(LCD _ busy());

LCD _ RS = 1;

LCD _ RW = 0;

P0 = dat

LCD _ E = 1;

LCD _ E = 0;

}

void lcd_initial()

{

LCD _ wcmd(0x 30);

Delay (1);

LCD _ wcmd(0x0C); //Turn on the monitor and turn off the cursor without blinking.

Delay (1);

LCD _ wcmd(0x 06); //Specifies the direction in which the cursor moves when writing or reading data.

Delay (1);

LCD _ wcmd(0x 0 1);

Delay (10); //The delay here is longer, otherwise it will affect the later operation.

}

/*-command to clear the screen */

void Clr_Screen()

{

//Considering the appearance of 0x34.

LCD _ wcmd(0x 0 1);

Delay (100);

}

Void _ FU(uchar code *s)

{

while(*s! =0)

{ LCD _ wdata(* s);

s++;

Delay (10);

}

}

Sense of emptiness 1 ()

{

LCD _ wcmd(0x 30);

Delay (300);

LCD _ wcmd(0x 80+first _ Addr);

zi _ FU(" 2065 438+03 03 26 ");

Delay (300);

LCD _ wcmd(0x 90+first _ Addr);

Zi_FU ("Electrical 08-17");

Delay (300);

LCD _ wcmd(0x 88+first _ Addr);

Sub _ operator ("nerdy");

Delay (300);

LCD _ wcmd(0x 98+first _ Addr);

Delay (500);

zi _ FU(" 2065 438+02 . 5 . 30 ");

}

void main()

{

PCB = 1;

while( 1)

{

LCD _ initial();

Delay (1000);

clr _ Screen();

Feeling1();

Delay (3000);

for(I = 8; I>0; I-)

{

LCD _ wcmd(0x 18); //Switch one or two lines to three or four lines, and the LCD is divided into two and a half screens.

Delay (1000);

}

clr _ Screen();

Feeling1();

LCD _ wcmd(0x 34);

LCD _ wcmd(0x 04);

Delay (3000);

LCD _ wcmd(0x 04); //Return to normal

Delay (3000);

LCD _ wcmd(0x 34);

LCD _ wcmd(0x 03); //Allows you to enter a scrolling address.

for(I = 0x 40; I & lt0x7fi++)

{

Lcd_wcmd (1); //Scroll the contents of the screen vertically.

Delay (600); //Increase the screen delay

}

}

}