搜索
您的当前位置:首页正文

出租车计程表程序

2023-08-25 来源:星星旅游


#include #define uint unsigned int #define uchar unsigned char uint i,sum; uchar

code

table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; sbit dula=P2^6; sbit wela=P2^7;

uchar bai,shi,ge,shifen,baifen,qianfen; void delay(uchar z) {

uchar x,y; for(x=z;x>0;x--) for(y=110;y>0;y--);

} void init() { EX0=1; EA=1; IT0=1; }

void ex0_isr() interrupt 0 { i++;

sum=i*4*0.008*100; bai=sum/10000; shi=sum/1000%10; ge=sum/100%10; shifen=sum/10%10;

baifen=sum%10; if(baifen>4) shifen=shifen++; else shifen=shifen; }

void display() { dula=0; wela=0; P0=0x01; wela=1; wela=0; P0=table[bai]; dula=1; dula=0;

delay(5); P0=0x02; wela=1; wela=0; P0=table[shi]; dula=1; dula=0; delay(5); P0=0x04; wela=1; wela=0;

P0=table[ge]&0x7f; dula=1; dula=0; delay(5);

P0=0x08; wela=1; wela=0;

P0=table[shifen]; dula=1; dula=0; delay(5); /* P0=0x10; wela=1; wela=0;

P0=table[baifen]; dula=1; dula=0; delay(5); P0=0x20;

wela=1; wela=0;

P0=table[qianfen]; dula=1; dula=0; delay(5); */ }

void main() { init(); while(1) { display(); } }

因篇幅问题不能全部显示,请点此查看更多更全内容

Top