有点复杂,,,,,,,,,,, |
哪里买的单片机 |
void xsdata(uchar aa,uchar bb,uchar cc,uchar dd)//显示函数 { /******* aa=shu/1000; bb=shu%1000/100; ********/ aa=num%100/10; bb=num%10; cc=shu%100/10; dd=shu%10; we1=0; P0=table[aa]; delay_50ms(10); P0=0xff; we1=1; we2=0; P0=table[bb]; delay_50ms(10); P0=0xff; we2=1; we3=0; P0=table[cc]; delay_50ms(10); P0=0xff; we3=1; we4=0; P0=table[dd]; delay_50ms(10); P0=0xff; we4=1; } |
/************中断函数****************/ void timer0() interrupt 1 //中断函数 { uchar t0; TH0=(65536-50000)/256; TL0=(65536-50000)%256; t0++; if(t0==20) { t0=0; shu--; if(shu==0) { shu=shu1; num--; if(num==0) { P1<<=1; P1=P1|0x01; //左移后,最右端自动赋值0,所以需要该语句赋值1 if(P1==0x7f) P1=0xfe; num=num1; } } } } |
/************按键控制部分****************/ void key() //按键 { if(s1==0) { delay_50ms(10); if(s1==0) { while(!s1); c1++; } } if(c1==1) //时间设置 { if(s2==0) { delay_50ms(5); if(s2==0) { while(!s2); shu1--; } } if(s3==0) { delay_50ms(5); if(s3==0) { while(!s3); shu1++; } } } if(c1==2) //循环次数设置 { if(s2==0) { delay_50ms(5); if(s2==0) { while(!s2); num1--; } } if(s3==0) { delay_50ms(5); if(s3==0) { while(!s3); num1++; } } } } |