?? lcd1602.h
字號:
//#include "AT89X51.H"
#define Ddata P0
sbit RS=P2^5;
sbit RW=P2^6;
sbit LCDE=P2^7;
//1PIN--GND 2PIN--VCC 3PIN--VO 4PIN--RS 5PIN--RW 6PIN--E 7-14PIN--DB0-DB7 15PIN--A 16PIN--K
unsigned char hour=12,min=0,sec=0;
unsigned int count=0;
unsigned char line1[16]={"www.gliet.edu.cn"};
unsigned char line2[16]={"Gui Lin 12:00:00"};
unsigned char tab[]={'0','1','2','3','4','5','6','7','8','9'};
void delay5ms()
{unsigned int i;
for (i=0;i<1000;i++);
}
void delay50us()
{register int i;
for (i=0;i<20;i++);
}
/*
void delay()
{unsigned char m,n;
for(m=255;m>0;m--)
for(n=255;n>0;n--);}
*/
wr_com(unsigned char comm)//********寫控制字符程序 E=1 RS=0 RW=0**********//
{
LCDE=0;
RS=0; //********RS寄存器選擇輸入端,當(dāng)RS=0;當(dāng)進(jìn)行寫模塊操作,指向指令寄存器。
RW=0; //********當(dāng)RS=1,無論是讀操作還是寫操作,都是指向數(shù)據(jù)寄存器。
LCDE=1;
Ddata=comm;
RS=0;
RW=0;
LCDE=0;
}
wr_data(unsigned char dat)//*****當(dāng)前位置寫字符子程序:E=1 RS=1 RW=0
{
LCDE=0;
RS=0; //********RS寄存器選擇輸入端,當(dāng)RS=0;當(dāng)進(jìn)行寫模塊操作,指向指令寄存器。
RW=0; //********當(dāng)RS=1,無論是讀操作還是寫操作,都是指向數(shù)據(jù)寄存器。
RS=1;
RW=0;
LCDE=1;
Ddata=dat;
LCDE=0;
RS=0;
RW=0;
}
unsigned char busycheck()//*****忙狀態(tài)檢查*******//
{
unsigned char i;
LCDE=0;
RS=0;
RW=0;
RS=0;
RW=1;
LCDE=1;
i=Ddata;
LCDE=0;
return(i);
}
void init()//**********初始化程序,必須按照產(chǎn)品的資料介紹的過程進(jìn)行********//
{
wr_com(0x38); //*****顯示模式設(shè)置必須三次,不用檢測忙信號
delay5ms();
wr_com(0x38);
delay5ms();
wr_com(0x38);
delay5ms();
wr_com(0x01); ///***清屏****
delay5ms();
busycheck();
delay5ms();
wr_com(0x06); ///****光標(biāo)移動(dòng)設(shè)置***
delay5ms();
busycheck();
delay50us();
wr_com(0x38); ////***顯示模式設(shè)置****
delay50us();
busycheck();
delay50us();
wr_com(0x0c); /////***顯示開***
delay50us();
busycheck();
delay50us();
wr_com(0x40); //set cgram address
delay50us();
delay50us(); //***這些延時(shí)可用可不用***//
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -