如何用keil和proteus点亮流水灯

来源:互联网 发布:ubuntu 17.04更新源 编辑:程序博客网 时间:2024/04/30 12:54

代码:

#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
uchar temp[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0xff};
void delay(uint z)
{
 uint x,y;
 for(x=100;x>0;x--)
  for(y=z;y>0;y--);
}
void main()
{
 uchar i; 
  while(1)
{
   for(i=0;i<9;i++)    
 {
   P0=temp[i];
   delay(400);
 }
   for(i=0;i<9;i++)
 {
  P1=temp[i];
   delay(400);
 }
}
}

proteus中电路图

点亮流水灯有4种方法

1、最基础的方法,分条列举出来

2、先左移,后或

3、调用左移函数_crol_()

4、使用数组{0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f}

原创粉丝点击