效果图表:
电路图:
#包含
#include //中包含由_nop_ ()函数定义的头文件
#define uchar unsigned char
#定义uint unsigned int
sbit RS=P2^5; //寄存器选择位
sbit RW=P2^6; //读写选择位
sbit E=P2^7; //使能信号位
//sbit BF=P0^7; //忙碌的标志位
constucharstring1[ ]={ ' ma Zirong ' };
constucharstring2[ ]={ ' tel :13297961386 ' };
/* * * * * * * * * * * * * * * * * *
函数功能:判断液晶模块的繁忙状态
返回值: result。 result=1,忙; result=0,不忙
* * * * * * * * * * * * * * * *
/*uchar BusyTest () ) ) )。
{
比特结果;
RS=0; //根据规定,RS为低电平、RW为高电平时,可以读取状态
RW=1;
E=1; //E=1后才允许读写
_nop_ (); //空操作
_nop_ ();
_nop_ ();
_nop_ ();//空操作4个机器周期,给硬件反应时间
result=BF; //将繁忙标志的级别分配给result
E=0;
返回结果;
() /
//*******延迟
电压延迟(ucharz ) ) ) ) ) ) ) ) )。
{
uchar i,j;
for(I=z; i0; I----;
for(j=110; j0; j----;
}
//*******写命令
语音描述(用户检测)。
{
//while(busytest ()==1);
RS=0; //规定,RS和R/W同时为低电平时,可以写入指令
RW=0;
E=0; //E为低电平()编写指令时,e为高脉冲() ) ) ) )。
//E从0正转到1,所以先放“0”
P0=dictate; //将数据送入P0端口,即写入命令和地址
dlay(1;
/*_nop_ ();
_nop_ ();
_nop_ ();
_ nop_ (); */
E=1; //E设为高电平
_nop_ ();
_nop_ ();
_nop_ ();
_nop_ ();//空操作4个机器周期,给硬件反应时间
E=0; //e从高电平跳到低电平时,液晶模块开始执行命令
}
//*******写数据
语音写入数据(uchar dat )。
{
//while(busytest ()==1);
RS=1; //RS为高电平、RW为低电平时,可以写入数据
RW=0;
E=0; //(写命令时,e为高脉冲) ) )。
//E从0正转到1,所以先放“0”
P0=dat; 向//p0端口送入数据,向液晶模块写入数据
dlay(1;
/*_nop_ ();
_nop_ ();
_nop_ ();
_ nop_ (); */
E=1; //E设为高电平
_nop_ ();
_nop_ ();
_nop_ ();
_nop_ ();//空操作4个机器周期,给硬件反应时间
E=0; //e从高电平跳到低电平时,液晶模块开始执行命令
}
//*******初始化
语音识别(语音) )。
{
witeinstruction(0x38; //显示模式设定: 162显示、57点、8位数据接口
witeinstruction(0x0c; //显示模式设定:打开,显示无光标
witeinstruction(0x06; //显示模式设定:光标向右移动,文字不动
witeinstruction(0x01; //清除屏幕指令,清除以前的显示内容
}
//******主函数
语音主(语音) )。
{
uchar a;
Init (;
while(1)。
{
a=0;
witeinstruction(0x80; //将显示位置设为第1行的第1个字符
while (字符串1 [ a ]!=' ' )/'"是数组结束标志
{
写入数据(字符串1 [ a ];
A;
}
a=0;
witeinstruction(0x800x40 ); //将显示位置设为第2行的第1个字符
while (字符串2 [ a ]!=' ' )/'"是数组结束标志
{
write data (字符串2 [ a ];
A;
}
}
}