资源描述:
《程序代码文档》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、#includeunsignedcharcodetable[]={0xf1,0xf3,0xf2,0xf6,0xf4,0xfc,0xf8,0xf9,0x00,0xf1,0xf9,0xf8,0xfc,0xf4,0xf6,0xf2,0xf3,0x00};unsignedchartemp,temp_old;unsignedcharkey;unsignedchari,j,k,m,s;voiddelay(inti){for(m=i;m>0;m--)for(j=250;j>0;j--)for(k=10;k
2、>0;k--);}voidsaomiao(){P3=0xff;P3_4=0;temp=P3;temp=temp&0x0f;if(temp!=0x0f){for(i=50;i>0;i--)for(j=200;j>0;j--);temp=P3;temp=temp&0x0f;if(temp!=0x0f){temp=P3;temp=temp&0x0f;switch(temp){case0x0e:key=1;break;case0x0d:key=2;break;case0x0b:key=3;break;case0x07:k
3、ey=4;break;}temp=P3;temp=temp&0x0f;while(temp!=0x0f){temp=P3;temp=temp&0x0f;}}}P3=0xff;P3_5=0;temp=P3;temp=temp&0x0f;if(temp!=0x0f){for(i=50;i>0;i--)for(j=200;j>0;j--);temp=P3;temp=temp&0x0f;if(temp!=0x0f){temp=P3;temp=temp&0x0f;switch(temp){case0x0d:key=5;br
4、eak;case0x0b:key=6;break;case0x07:key=7;break;}temp=P3;temp=temp&0x0f;while(temp!=0x0f){temp=P3;temp=temp&0x0f;}}}}voidmain(void){while(1){saomiao();if(key==1){P1=0;P2=0;saomiao();}if(key==2){temp_old=key;for(s=0;s<8;s++){P2=table[s];P1_4=0;delay(13);saomiao(
5、);if(key!=temp_old){P1_4=1;break;}}}if(key==3){temp_old=key;for(s=0;s<8;s++){P2=table[s];P1_5=0;delay(5);saomiao();if(key!=temp_old){P1_5=1;break;}}}if(key==4){temp_old=key;for(s=0;s<8;s++){P2=table[s];P1_6=0;delay(20);saomiao();if(key!=temp_old){P1_6=1;break
6、;}}}if(key==5){temp_old=key;for(s=9;s<17;s++){P2=table[s];P1_7=0;delay(13);saomiao();if(key!=temp_old){P1_7=1;break;}}}if(key==6){temp_old=key;for(s=9;s<17;s++){P2=table[s];P1_5=0;delay(5);saomiao();if(key!=temp_old){P1_5=1;break;}}}if(key==7){temp_old=key;fo
7、r(s=9;s<17;s++){P2=table[s];P1_6=0;delay(20);saomiao();if(key!=temp_old){P1_6=1;break;}}}}}