《单片机原理及应用》第二版例5-2
参考代码如下:
#include <REGX52.H>
#include<intrins.h> //包含循环左、右移位函数的头文件
#define uchar unsigned char
void delay()//延时函数
{
uchar i=255,j;
while(i--)
{
for(j=0;j<255;j++);
}
}
//方法一:数组的字节操作实现
//本方法是通过建立1个字符型数组,将控制8个LED显示的8位数据作为数组元素,依次送到P1口来实现。
void main()
{
uchar tab[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
uchar i;
while(1)
{
for(i=0;i<16;i++)
{