-
大小: 3KB文件類(lèi)型: .c金幣: 1下載: 0 次發(fā)布日期: 2021-06-09
- 語(yǔ)言: 其他
- 標(biāo)簽:
資源簡(jiǎn)介
1602LCD顯示電話撥號(hào)鍵盤(pán)按鍵,提供顯示電話撥號(hào)鍵盤(pán)按鍵.
代碼片段和文件信息
#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讀、寫(xiě)控制
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();
?//---------------------------------------------------------------------------
?//顯示函數(shù),在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;
}
?//----------------------------------------------------------------------------------
?//寫(xiě)數(shù)
評(píng)論
共有 條評(píng)論