资源简介
1602LCD显示电话拨号键盘按键,提供显示电话拨号键盘按键.
代码片段和文件信息
#include
#include
#include
#define uchar unsigned char
#define uint unsigned int
#define delaynop() {_nop_();_nop_();_nop_();_nop_();}
sbit RS=P2^6; //LCD寄存器选择
sbit RW=P2^5; //LCD读、写控制
sbit EN=P2^7; //LCD启用
sbit BEEP=P1^5;
char code title_Text[]={“ --Phone Code-- “};
uchar code Key_Table[]={‘1‘‘2‘‘3‘‘4‘‘5‘‘6‘‘7‘‘8‘‘9‘‘*‘‘0‘‘#‘};
uchar Dial_Code_Str[]={“ “};
uchar KeyNo=0xFF;
int tCount=0;
void DelayMS(uint x)
{
uchar i;
while(--x) for(i=0;i<120;i++);
}
bit LCD_Busy();
void LCD_Wcmd(uchar cmd);
void LCD_Wdat(uchar str);
void LCD_Pos(uchar pos);
void LCD_Init();
//---------------------------------------------------------------------------
//显示函数,在LCD指定的行上显示字符串
//----------------------------------------------------------------------------
void Display_String( uchar *str uchar LineNo )
{
uchar k;
LCD_Pos(LineNo);
for(k=0;k<16;k++) LCD_Wdat(str[k]);
}
//----------------------------------------------------------------------------------
//LCD忙等待
//----------------------------------------------------------------------------------
bit LCD_Busy()
{
bit result;
RS=0;RW=1;EN=1;delaynop();
result=(bit)(P0&0x80);
EN=0;
return result;
}
//---------------------------------------------------------------------------------
//下指令
//----------------------------------------------------------------------------------
void LCD_Wcmd(uchar cmd)
{
while(LCD_Busy());
RS=0;RW=0;EN=0; _nop_();_nop_();
P0=cmd;delaynop();
EN=1;delaynop(); EN=0;
}
//----------------------------------------------------------------------------------
//写数
评论
共有 条评论