标题: 求大佬注释一下这个单片机程序 [打印本页]

作者: 低调啊    时间: 2019-6-24 15:10
标题: 求大佬注释一下这个单片机程序
#include <AT89X52.H>
unsigned char tab[] = {
  0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,
  0x7F,0x6F,0x77,0x7C,0x39,0x5E,0x79,0x71,0xFF,0x00};
  
void delayms(unsigned int t)
{
unsigned char a,b,c,d;
for(d=t;d>0;d--)
  for(c=1;c>0;c--)
   for(b=222;b>0;b--)
    for(a=12;a>0;a--);
}

void main (void)
{
unsigned char size = sizeof(tab)/sizeof(tab[0]);
unsigned char i = 0;
unsigned char state = 0;
while(1)
{
  if(0 == P1_0)
  {
   delayms(10);
   if(0 == P1_0)
   {
    for(i=0;i<100;i++)
     if(0==P1_0)i = 0;
   }
   state = 0;
  }
  if(0 == P1_1)
  {
   delayms(10);
   if(0 == P1_1)
   {
    for(i=0;i<100;i++)
     if(0==P1_1)i = 0;
   }
   state += 1;
  }
  if(0 == P1_2)
  {
   delayms(10);
   if(0 == P1_2)
   {
    for(i=0;i<100;i++)
     if(0==P1_2)i = 0;
   }
   state -= 1;
  }
  if(0 == P1_3)
  {
   delayms(10);
   if(0 == P1_3)
   {
    for(i=0;i<100;i++)
     if(0==P1_3)i = 0;
   }
   state = size-1;
  }
  state %= size;
  P0 = ~tab[state];
   
}
}







欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1