《初学者C51自学笔记》之流水灯实现(总线操作)

#include <reg52.h>
#define uchar unsigned char //宏定义
#define uint unsigned int

unsigned char table[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};//11111110,11111101,11111011.....
/*
    延时
*/
void delay(void)
{
	uchar a,b;
	for(a=0;a<200;a++)
	for(b=0;b<200;b++);
}

void main()
{
	uchar i;
	while(1)
	{
	    for(i=0;i<8;i++)
	    {
	    P0=table[i];
	    delay();
	    }
    }
}

猜你喜欢

转载自blog.csdn.net/qq_40691438/article/details/81382624