仿真文件的下载地址:http://www.51hei.com/f/csdwpjs.rar
#include"lcd1602.h"
#define uchar unsigned char
#define uint unsigned int
uchar out[6];
sbit STAR_KEY =P3^2;//定义键与单片机的连接引脚
sbit L0=P1^0; //定义SFR中引脚的位
sbit L1=P1^1;
sbit L2=P1^2;
sbit L3=P1^3;
sbit L4=P1^4;
sbit L5=P1^5;
sbit L6=P1^6;
sbit L7=P1^7;
sbit MOTOR=P3^0;
uchar n[2]={1,0};
void delayms(uint x) //延时子程序
{
uchar y;
while(x--)
{
for(y=0;y<123;y++){;}
}
}
uchar Keynum() //按键子程序1
{
uchar key=0;
STAR_KEY=1; //置初值
if(STAR_KEY==0){delayms(10);if(STAR_KEY==0)n[0]=0;n[1]=1;} //按下STAR键则n[0]=0;n[1]=1
return n[1]; //返回n值
}
void xianshi(uint dispbuf) //显示子程序
{
out[0]=dispbuf/10000+0x30;
out[1]=((dispbuf%10000)/1000)+0x30;
out[2]=((dispbuf%1000)/100)+0x30;
out[3]=((dispbuf%100)/10)+0x30;
out[4]=dispbuf%10+0x30;
out[5]='