您的位置 首页 FPGA

单片机制造超级流水灯

实验源程序:includereg52h>includeintrinsh>unsignedinta,b;unsignedchard;sbitLED1=P1^0;sbitLED2=P1^1;s

试验源程序:

#include
#include
unsigned int a,b;
unsigned char d;
sbit LED1 = P1^0;
sbit LED2 = P1^1;
sbit LED3 = P1^2;
sbit LED4 = P1^3;
sbit LED5 = P1^4;
sbit LED6 = P1^5;
sbit LED7 = P1^6;
sbit LED8 = P1^7;
sbit LED9 = P2^0;
sbit LED10 = P2^1;
sbit LED11 = P2^2;
sbit LED12 = P2^3;
sbit LED13 = P2^4;
sbit LED14 = P2^5;
sbit LED15 = P2^6;
sbit LED16 = P2^7;
sbit LED17 = P3^0;
sbit LED18 = P3^1;
sbit LED19 = P3^2;
sbit LED20 = P3^3;
sbit LED21 = P3^4;
sbit LED22 = P3^5;
sbit LED23 = P3^6;
sbit LED24 = P3^7;

void Delay()
{
for(a=100;a>0;a–)
for(b=100;b>0;b–);
}

void main()
{
while(1)
{
P1 = 0;
P2 = 0;
P3 = 0;
LED1 = 1;
Delay();
LED1 = 0;
LED2 = 1;
Delay();
LED2 = 0;
LED3 = 1;
Delay();
LED3 = 0;
LED4 = 1;
Delay();
LED4 = 0;
LED5 = 1;
Delay();
LED5 = 0;
LED6 = 1;
Delay();
LED6 = 0;
LED7 = 1;
Delay();
LED7 = 0;
LED8 = 1;
Delay();

LED8 = 0;
LED9 = 1;
Delay();
LED9 = 0;
LED10 = 1;
Delay();
LED10 = 0;
LED11 = 1;
Delay();
LED11 = 0;
LED12= 1;
Delay();
LED12 = 0;
LED13= 1;
Delay();
LED13= 0;
LED14= 1;
Delay();
LED14= 0;
LED15= 1;
Delay();
LED15 = 0;
LED16= 1;
Delay();

LED16 = 0;
LED17= 1;
Delay();
LED17 = 0;
LED18 = 1;
Delay();
LED18 = 0;
LED19= 1;
Delay();
LED19 = 0;
LED20= 1;
Delay();
LED20= 0;
LED21= 1;
Delay();
LED21= 0;
LED22= 1;
Delay();
LED22 = 0;
LED23= 1;
Delay();
LED23 = 0;
LED24= 1;
Delay();
}
}

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/fangan/fpga/261678.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部