#include
#define uint unsigned int#define uchar unsigned charsbit rck=P0^0;sbit sck=P0^1;sbit si=P0^2;sbit key1=P1^0;//按键接在P1^0口sbit key2=P1^1;//按键接在P1^1口uint b=0,a=0,c=0;//大局界说并赋初值uchar code num[]={0x80,0xed,0x42,0x48,0x2c,0x18,0x10,0xcc,0x00,0x08};void write_date(uchar temp){uint i;for(i=0;i<8;i++){temp>>=1;sck=0;si=CY;sck=1;}}void key(){if(key1==0)//假如按键1被拉为低电平{ while(!key1);//由低电平变为高电平(即手松开),则履行下面句子b++; if(b==9)b=0;//假如b=0,则从头调零 }else if(key2==0)//剖析办法同key1{while(!key2);a++;if(a==9)a=0;}write_date(num[b]);write_date(num[a]); rck=0;rck=1;}void main(){ write_date(num[0]);write_date(num[0]); while(1)//扫描按键是否被按,假如其间的一个被按或两个一起被按,则履行{ key();//调用key函数 } }