/*----------------------------------------------- 内容:通过标准程序静态显示字符 引脚定义如下:1-VSS 2-VDD 3-V0 4-RS 5-R/W 6-E 7-14 DB0-DB7 15-BLA 16-BLK------------------------------------------------*/#include //包含头文件,一般情况不需要改动,头文件包含特别功能寄存器的定义#includesbit RS = P2^0; //定义端口 sbit RW = P2^1;sbit EN = P2^2;sbit echo=P1^1; //接收端sbit trig=P1^0; //发射端sbit Beap=P2^3; //蜂鸣器sbit Key_Data=P2^4; //按键发射#define RS_CLR RS=0 #define RS_SET RS=1#define RW_CLR RW=0 #define RW_SET RW=1 #define EN_CLR EN=0#define EN_SET EN=1#define DataPort P0unsigned char code ASCII[15] = {'0','1','2','3','4','5','6','7','8','9','.','-','M'};unsigned char disbuff[4] ={ 0,0,0,0,};unsigned long S=0;unsigned char Flag;unsigned int time;unsigned int t=500;/*------------------------------------------------ uS 延时函数,含有输入参数 unsigned char t,无返回值 unsigned char 是定义无符号字符变量,其值的范围是 0~255 这里使用晶振 12M,精确延时请使用汇编,大致延时 长度如下 T=tx2+5 uS ------------------------------------------------*/void DelayUs2x(unsigned char t){ while(--t);}/*------------------------------------------------ mS 延时函数,含有输入参数 unsigned char t,无返回值 unsigned char 是定义无符号字符变量,其值的范围是 0~255 这里使用晶振 12M,精确延时请使用汇编------------------------------------------------*/void DelayMs(unsigned char t){ while(t--) { //大致延时 1mS DelayUs2x(245); DelayUs2x(245); }}/*------------------------------------------------ 判忙函数------------------------------------------------*/ bit LCD_Check_Busy(void) { DataPort= 0xFF; RS_CLR; RW_SET; EN_CLR; _nop_(); EN_SET; return (bit)(DataPort & 0x80); }/*------------------------------------------------ 写入命令函数------------------------------------------------*/ void LCD_Write_Com(unsigned char com) { while(LCD_Check_Busy()); //忙则等待...