1、 选手1 按钮P1:灯P0:数码管P2;P3八0主持人控制开关 # iiiclude frdefine uc unsigned chai sbit lil=P0八0; sbit li2=P0z1; sbit li3=P0八2; sbit li4=P0、3; sbit li5=P0八4; sbit li6=P0A5; sbit li7=POz6; sbit 118=POA7;定义灯 sbit kevl=Plz0; J7 sbit kev2=Plz1; J7 sbit key3=PlA2; sbit kev4=PlA3; sbit kev5=PT 4; sbit kev6=PlA5; sbit k
2、ev7=Pr 6; sbit kev8=PlA7;定义按钮 sbit zliuchi=P3A0; uc code table= 0 x3f,0 x06,0 x5b,0 x4f,0 x66, 0 x6d,0 x7d,0 x07,0 x7f0 x6fi0 x77,0 x7c,0 x39,0 x5e,0 x79,0 x71; void delay(uc xms); void main() if(keyl=O) delay(lO);去抖延时if(keyl=O) P2=tablel;hl=0; wlule(l) if(zliuclu=O) delay(lO); if(zliuclu=O) P2=OxOO
3、;Ul=l;break; P2=0 x00; while(l) 共阴数码管全灭 选手1 选手2 选手1 if(key2=0) if(kev5=O)选手5 delay(lO);去抖延时if(key2=0) P2=table2;U2=O; wlule(l) if(zliuclu=O)delay(lO);if(zliuclu=O) P2=0 x00;li2= 1 ;break; 选手2 if(kev3=O) delay(lO);去抖延时if(key3=O) P2=table3;U3=O; wlule(l) if(zliuclu=O)delay(lO); if(zliuclu=O)P2=OxOO;U3
4、= 1 ;break; 选手3 if(kev4=0) delay(lO);去抖延时if(key4=0) P2=table4;U4=0; wlule(l) if(zliuclu=O)delay(lO); if(zliuclu=O)P2=0 x00;H4= 1 ;break; 选手4 delay(lO);去抖延时 选手3 选手4 if(key5=0) P2=table5;U5=0; wlule(l) if(zliuclu=O)delay(lO);if(zliuclu=O) P2=OxOO;H5= 1 ;break; 选手5 if(kev6=0) delay(lO);去抖延时if(key6=0) P
5、2=table6;h6=0; wlule(l) if(zliuclu=O)delay(lO); if(zliuclu=O)P2=OxOO;U6= 1 ;break; 选手6 if(kev7=O) delay(lO);去抖延时if(key7=O) P2=table7;h7=O; wlule(l) if(zliuclu=O)delay(lO); if(zliuclu=O)P2=OxOO;U7= 1 ;break; 选手7 if(kev8=O) delay(lO);去抖延时if(key8=O) P2=table8;h8=O; wlule(l) if(zliuclu=O) delay(lO); if(zliuclu=O) P2=OxOO;H8= 1 ;break; 选手8 void delay(uc xins)延时函数 选手6 选手7 选手8 UC ij; fbr(i=xius;iO;i-) for(j=110j0j-);