出租车计价器代码
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
出租车计价器代码
#include<reg52.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
#define delayNOP(); {_nop_();_nop_();_nop_();_nop_();_nop_();}; uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; sbit exter=P3^3; //外部中断
sbit key0=P1^0; //清零
sbit key1=P1^1; //切换/+
sbit key2=P1^2; //-
sbit key3=P1^3; //功能键
sbit SCL=P2^2;
uint inter,aa,bb,temp,temp1,numwei;
uint zongjine,licheng,dengdai;
uint zongjine1,licheng1;
uint key3num,qiehuantemp,delaytemp;
uchar danjia1,danjia2,danjia3,danjia,qibu;
void delay(uint x) //延时时基为1ms
{
int i,j;
for(i=x;i>0;i--)
for(j=340;j>0;j--);
}
void display() //数码管显示
{
//数码管动态显示
switch(numwei)
{
case 0:P3=0xfe;P0=table[zongjine/100];break;
case 1:P3=0xfd;P0=table[zongjine%100/10]+0x80;break;
case 2:P3=0xfb;P0=table[zongjine%100%10];break;
case 3:P3=0xef;P0=table[licheng/10];break;
case 4:P3=0xdf;P0=table[licheng%10];break;
case 5:P3=0xbf;P0=table[danjia/10]+0x80;break;
case 6:P3=0x7f;P0=table[danjia%10];break;
}
if(numwei==7)
numwei=0;
}
void keyscan() //键盘扫描
{
if(key3==0) //功能键调节{
delay(5);
if(key3==0)
{
key3num++;
if(key3num==5) key3num=0;
while(!key3);
delay(5);
while(!key3);
while(key3num)
{
if(key3num==1) //调白天单价{
if(key1==0)
{
delay(5);
if(key1==0)
{
danjia1++;
if(danjia1==100)
danjia1=0;
while(!key1);
delay(5);
while(!key1);
}
}
if(key2==0)
{
delay(5);
if(key2==0)
{
danjia1--;
if(danjia1==-1)
while(!key2);
delay(5);
while(!key2);
}
}
zongjine=100;
licheng=0;
danjia=danjia1;
}
if(key3num==2) //调夜晚单价{
if(key1==0)
{
delay(5);
if(key1==0)
{
danjia2++;
if(danjia2==100)
danjia2=0;
while(!key1);
delay(5);
while(!key1);
}
}
if(key2==0)
{
delay(5);
if(key2==0)
{
danjia2--;
if(danjia2==-1)
danjia2=99;
while(!key2);
delay(5);
while(!k
ey2);
}
}
zongjine=200;
danjia=danjia2;
}
if(key3num==3) //调等待单价{
if(key1==0)
{
delay(5);
if(key1==0)
{
danjia3++;
if(danjia3==100)
danjia3=0;
while(!key1);
delay(5);
while(!key1);
}
}
if(key2==0)
{
delay(5);
if(key2==0)
{
danjia3--;
if(danjia3==-1)
danjia3=99;
while(!key2);
delay(5);
while(!key2);
}
}
zongjine=300;
licheng=0;
danjia=danjia3;
}
if(key3num==4) //调起步价
{
if(key1==0)
{
delay(5);
if(key1==0)
{