欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: 16按鍵數字顯示程序 [打印本頁]

作者: 唐長老    時間: 2016-12-11 21:29
標題: 16按鍵數字顯示程序


  1. #include <regx51.h>
  2. void delayms(unsigned int i)
  3. {
  4. unsigned char k;
  5. while(i--)
  6. for(k=0;k<120;k++);
  7. }
  8. char scan_key ();
  9. void main()
  10. {
  11. unsigned char led[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};
  12. unsigned char i;
  13. P1=0xff;
  14. P0=0xff;
  15. while(1)
  16. {
  17.   i=scan_key();
  18.   if(i==-1)continue;
  19.   else
  20.   P1=led[i];
  21. }
  22. }
  23. char scan_key ()
  24. {
  25. char i, temp,m,n;
  26. bit find=0;
  27. P2=0xf0;
  28. i=P0;
  29. i&0x0f;
  30. if(i!=0x0f)
  31. {
  32.   delayms(10);
  33.   i=P0;
  34.   i&0x0f;
  35.   if(i!=0x0f)
  36.   {
  37.    for(i=0;i<4;i++)
  38.    {
  39.     P2=0xfe<<i;
  40.     temp=~P0;
  41.     temp=temp&0x0f;
  42.     if(temp!=0x00)
  43.     {
  44.      m=i;
  45.      find=1;
  46.      switch(temp)
  47.      {
  48.       case 0x01:n=0;break;
  49.       case 0x02:n=1;break;
  50.       case 0x04:n=2;break;
  51.       case 0x08:n=3;break;
  52.       default:break;
  53.      }
  54.      break;
  55.     }
  56.    }
  57.   }
  58. }
  59. if(find==0) return -1;
  60. else return(n*4+m);
  61. }
復制代碼





歡迎光臨 (http://www.raoushi.com/bbs/) Powered by Discuz! X3.1