找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1157|回复: 0
收起左侧

求大佬注释一下这个单片机程序

[复制链接]
ID:570860 发表于 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];
   
}
}


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表