#2
r3169994432020-11-16 20:07
|
#include<reg51.h>
#include<intrins.h>
Sbit K1=P3^0;
Sbit K1=P3^1;
Sbit K1=P3^2;
sbit LED1=P2^0£»
sbit LED2=P2^1£»
sbit LED3=P2^2£»
void delay(unsigned int delaytime)
{
unsigned char i;
for(;delaytime>0;delaytime--)
for(i=250;i>0;i--)
;
}
void LED()
{
while(1)
{
unsigned char light=0xfe,i;
if(K1==0)
for(i=0;i<8;i++)
{
P2=light;
light=_crol_(light,1); //
delay(1000);
}
if(K1==1)
for(i=0;i<8;i++)
{
P2=light;
light=_cror_(light,1);
delay(1000);
}
if(K2==1)
{
P2=light;
P2=0xff;
delay(1000);
P2=0x7e;
delay(1000);
P2=0xbd;
delay(1000);
P2=0xdb;
delay(1000);
P2=0xe7;
delay(1000);
P2=0xff;
delay(1000);
}
if(K3==0)
for(i=0;i<8;i++)
{
P2=light;
light=_crol_(light,1);
P2=light|0xff ;
}
else
for(i=0;i<8;i++)
{
P2=0xff;
P2=light;
light=P2<<1;
delay(100);
}
for(i=0;i<8;i++)
{
P2=0x00;
P2=light;
light=P2>>1|0x80;
delay(100);
}
}
}