51单片机led控制c语言,51单片机控制LED(C语言).doc

//---------------------------------------------------

#include

//---------------------------------------------------

//重定义I/0引脚名称

sbit LED0=P1^0;

sbit LED1=P1^1;

sbit LED2=P1^2;

sbit LED00=P0^0;

sbit LED01=P0^1;

sbit LED02=P0^2;

sbit LED03=P0^3;

sbit LED04=P0^4;

sbit LED05=P0^5;

sbit LED06=P0^6;

sbit LED07=P0^7;

sbit LED20=P2^0;

sbit LED21=P2^1;

sbit LED22=P2^2;

sbit LED23=P2^3;

sbit LED24=P2^4;

sbit LED25=P2^5;

sbit LED26=P2^6;

sbit LED27=P2^7;

sbit LED30=P3^0;

sbit LED31=P3^1;

sbit LED32=P3^2;

sbit LED33=P3^3;

sbit LED34=P3^4;

sbit LED35=P3^5;

sbit LED36=P3^6;

sbit LED37=P3^7;

//固定函数声明

void delay(unsigned char z)

{

unsigned char x,y;

for(x=z;x>0;x--)

for(y=110;y>0;y--);

}

void as()

{

LED0=0;

LED00=0;

LED01=0;

LED02=0;

LED03=0;

LED04=0;

LED05=0;

LED06=0;

LED07=0;

delay(100);

LED0=1;

LED00=1;

LED01=1;

LED02=1;

LED03=1;

LED04=1;

LED05=1;

LED06=1;

LED07=1;

LED2=0;

LED30=0;

LED31=0;

LED32=0;

LED33=0;

LED34=0;

LED35=0;

LED36=0;

LED37=0;

delay(100);

LED2=1;

LED30=1;

LED31=1;

LED32=1;

LED33=1;

LED34=1;

LED35=1;

LED36=1;

LED37=1;

}

void main()

{

while(1)

{

LED1=0;

LED20=0;

LED21=0;

LED22=0;

LED23=0;

LED24=0;

LED25=0;

LED26=0;

LED27=0;

delay(10);

LED1=1;

LED20=1;

LED21=1;

LED22=1;

LED23=1;

LED24=1;

LED25=1;

LED26=1;

LED27=1;

as();

}

}

2

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
>