花样灯(一).c

来自「基于Proteus的51系列单片机设计与仿真」· C语言 代码 · 共 29 行

C
29
字号
/*************************************************************************************
                                  LED花样灯(一)
****************************************************************************************/
#include"reg51.h"
#define uint unsigned int
#define uchar unsigned char
const tab[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,     //正向流水灯
             0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,0xff,     //反向流水灯
             0xaa,0x55,0xaa,0x55,0xaa,0x55,0xff,          //隔灯闪烁
             0xf0,0x0f,0xf0,0x0f,0xff,                    //高四盏 底四盏闪烁
             0x33,0xcc,0x33,0xcc,0x33,0xcc,0xff,          //隔两盏闪烁 
            };
void delay(void)    //延时
{
      uint i;
	       for(i=0;i<34530;i++);
}

void main(void)
{
      uchar x;
         while(1)            
         {     
	               for(x=0;x<35;x++)
		              {   P2=tab[x];
					      delay();				  
					  }
         }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?