标题: 单数码管不改动数组进行逆循环的单片机程序问题 [打印本页]

作者: 哈哈哈1999    时间: 2019-4-25 23:38
标题: 单数码管不改动数组进行逆循环的单片机程序问题
  1.   #include<reg51.h>
  2.   unsigned char code duan[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
  3.   void delay(unsigned int t)
  4.   {unsigned int i,j;
  5.    for(i=0;i<t;i++)
  6.    for(j=0;j<120;j++);}
  7.    void main()
  8.    {unsigned char i=0;
  9.       while(1)
  10.    { for(i=0;i<10;i++)
  11.      {P3=duan[i];   
  12.    delay(500);
  13.          }}    }
复制代码

作者: wulin    时间: 2019-4-26 06:30
单数码管不改动数组进行逆循环的单片机程序

#include<reg51.h>

unsigned char code duan[]={
        0xc0,0xf9,0xa4,0xb0,0x99,
        0x92,0x82,0xf8,0x80,0x90};

void delay(unsigned int t)
{
        unsigned int i,j;
        for(i=0;i<t;i++)
                for(j=0;j<120;j++);
}
void main()
{
        unsigned char i;
        while(1)
        {
                for(i=10;i>0;i--)
                {
                        P3=duan[i-1];   
                        delay(500);
                }
        }
}
作者: 哈哈哈1999    时间: 2019-4-26 08:29
wulin 发表于 2019-4-26 06:30
单数码管不改动数组进行逆循环的单片机程序

#include

谢谢大佬




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