2019-07-18 10:31发布
sybdfu 发表于 2013-3-29 15:20 #include #define uchar unsigned char #define uint unsigned int
最多设置5个标签!
#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long
ulong LEDD;
sbit LED0 = P0^0;
sbit LED1 = P0^1;
sbit LED2 = P0^2;
sbit LED3 = P0^3;
sbit LED4 = P0^4;
sbit LED5 = P0^5;
sbit LED6 = P0^6;
sbit LED7 = P0^7;
sbit LED8 = P2^6;
sbit LED9 = P2^5;
sbit LED10 = P2^4;
sbit LED11 = P2^3;
sbit LED12 = P3^6;
sbit LED13 = P3^5;
sbit LED14 = P3^4;
sbit LED15 = P1^5;
sbit LED16 = P1^4;
sbit LED17 = P1^3;
sbit LED18 = P1^2;
sbit LED19 = P1^1;
sbit LED20 = P1^0;
void scan()
{
if(LEDD&0x000001) LED0=1;
else LED0=0;
if(LEDD&0x000002) LED1=1;
else LED1=0;
if(LEDD&0x000004) LED2=1;
else LED2=0;
if(LEDD&0x000008) LED3=1;
else LED3=0;
if(LEDD&0x000010) LED4=1;
else LED4=0;
if(LEDD&0x000020) LED5=1;
else LED5=0;
if(LEDD&0x000040) LED6=1;
else LED6=0;
if(LEDD&0x000080) LED7=1;
else LED7=0;
if(LEDD&0x000100) LED8=1;
else LED8=0;
if(LEDD&0x000200) LED9=1;
else LED9=0;
if(LEDD&0x000400) LED10=1;
else LED10=0;
if(LEDD&0x000800) LED11=1;
else LED11=0;
if(LEDD&0x001000) LED12=1;
else LED12=0;
if(LEDD&0x002000) LED13=1;
else LED13=0;
if(LEDD&0x004000) LED14=1;
else LED14=0;
if(LEDD&0x008000) LED15=1;
else LED15=0;
if(LEDD&0x010000) LED16=1;
else LED16=0;
if(LEDD&0x020000) LED17=1;
else LED17=0;
if(LEDD&0x040000) LED18=1;
else LED18=0;
if(LEDD&0x080000) LED19=1;
else LED19=0;
if(LEDD&0x100000) LED20=1;
else LED20=0;
}
void scan2()
{
if(LEDD&0x000001){LED0=1;}
else{LED0=0;}
if(LEDD&0x000002){LED1=1;}
else{LED1=0;}
if(LEDD&0x000004){LED2=1;LED20=1;}
else{LED2=0;LED20=0;}
if(LEDD&0x000008){LED3=1;LED19=1;}
else{LED3=0;LED19=0;}
if(LEDD&0x000010){LED4=1;LED18=1;}
else{LED4=0;LED18=0;}
if(LEDD&0x000020){LED5=1;LED17=1;}
else{LED5=0;LED17=0;}
if(LEDD&0x000040){LED6=1;LED16=1;}
else{LED6=0;LED16=0;}
if(LEDD&0x000080){LED7=1;LED15=1;}
else{LED7=0;LED15=0;}
if(LEDD&0x000100){LED8=1;LED14=1;}
else{LED8=0;LED14=0;}
if(LEDD&0x000200){LED9=1;LED13=1;}
else{LED9=0;LED13=0;}
if(LEDD&0x000400){LED10=1;LED12=1;}
else{LED10=0;LED12=0;}
if(LEDD&0x000800){LED11=1;}
else{LED11=0;}
}
/********************************************************************
* 名称 : delay(uint n)
* 功能 : 延时函数
* 输入 : n
* 输出 : 无
***********************************************************************/
void delay(uint n)
{
uint i;
for(i=0; i<n; i++);
}
/********************************************************************
* 名称 : delay_10ms(uint n)
* 功能 : 延时,延时时间为 10ms * n
* 输入 : n
* 输出 : 无
***********************************************************************/
void delay_10ms(uint n)
{
uint i,j;
for(i=0; i<n; i++)
for(j=0; j<1827; j++);
}
/********************************************************************
* 名称 : delay_10ms(uint n)
* 功能 : 延时,延时时间为 10ms * n
* 输入 : n
* 输出 : 无
***********************************************************************/
void delay_1ms(uint n)
{
uint i,j;
for(i=0; i<n; i++)
for(j=0; j<182; j++);
}
/********************************************************************
* 名称 : delay_10ms(uint n)
* 功能 : 延时,延时时间为 10ms * n
* 输入 : n
* 输出 : 无
***********************************************************************/
void delay_1(uint n)
{
uint i,j;
for(i=0; i<n; i++)
for(j=0; j<18; j++);
}
void VOL_1()
{
uint j,k;
ulong i;
k=1;
i=1;
while(i<=0x100000)
{
for(j=0;j<50;j++)
{
LEDD=i;
scan();
delay_1(k);
LEDD=0xffffffff;
scan();
delay_1(100-k);
}
i=i*2;
}
k=2;
i=3;
while(i<=0x200000)
{
for(j=0;j<50;j++)
{
LEDD=i;
scan();
delay_1(k);
LEDD=0xffffffff;
scan();
delay_1(70-k);
}
i=i*2;
}
k=3;
i=7;
while(i<=0x400000)
{
for(j=0;j<50;j++)
{
LEDD=i;
scan();
delay_1(k);
LEDD=0xffffffff;
scan();
delay_1(50-k);
}
i=i*2;
}
k=4;
i=15;
while(i<=0x800000)
{
for(j=0;j<50;j++)
{
LEDD=i;
scan();
delay_1(k);
LEDD=0xffffffff;
scan();
delay_1(40-k);
}
i=i*2;
}
k=5;
i=31;
while(i<=0x1000000)
{
for(j=0;j<50;j++)
{
LEDD=i;
scan();
delay_1(k);
LEDD=0xffffffff;
scan();
delay_1(30-k);
}
i=i*2;
}
k=6;
i=63;
while(i<=0x2000000)
{
for(j=0;j<50;j++)
{
LEDD=i;
scan();
delay_1(k);
LEDD=0xffffffff;
scan();
delay_1(20-k);
}
i=i*2;
}
k=7;
i=508;
while(i<=0x4000000)
{
for(j=0;j<50;j++)
{
LEDD=i;
scan();
delay_1(k);
LEDD=0xffffffff;
scan();
delay_1(15-k);
}
i=i*2;
}
k=8;
i=1020;
while(i<=0x8000000)
{
for(j=0;j<50;j++)
{
LEDD=i;
scan();
delay_1(k);
LEDD=0xffffffff;
scan();
delay_1(10-k);
}
i=i*2;
}
i=2044;
while(i<=0x10000000)
{
for(j=0;j<50;j++)
{
LEDD=i;
scan();
delay_1(8);
}
i=i*2;
}
i=0xffffff83;
while(i>0xf0000000)
{
for(j=0;j<50;j++)
{
LEDD=i;
scan();
delay_1(5);
}
i=i*2+1;
}
i=0xffffffc3;
while(i>0xf0000000)
{
for(j=0;j<50;j++)
{
LEDD=i;
scan();
delay_1(5);
}
i=i*2+1;
}
i=0xffffffe3;
while(i>0xf0000000)
{
for(j=0;j<50;j++)
{
LEDD=i;
scan();
delay_1(5);
}
i=i*2+1;
}
i=0xfffffff3;
while(i>0xf0000000)
{
for(j=0;j<50;j++)
{
LEDD=i;
scan();
delay_1(5);
}
i=i*2+1;
}
i=0xfffffffb;
while(i>0xf0000000)
{
for(j=0;j<50;j++)
{
LEDD=i;
scan();
delay_1(5);
}
i=i*2+1;
}
i=0xfffffffb;
while(i>0xf0000000)
{
for(j=0;j<50;j++)
{
LEDD=i;
scan();
delay_1(10);
}
i=i*2+1;
}
i=0xfffffffb;
while(i>0xf0000000)
{
for(j=0;j<50;j++)
{
LEDD=i;
scan();
delay_1(20);
}
i=i*2+1;
}
i=0xfffffffb;
while(i>0xf0000000)
{
for(j=0;j<50;j++)
{
LEDD=i;
scan();
delay_1(40);
}
i=i*2+1;
}
LEDD=0xffffffff;
scan();
delay_10ms(500);
LEDD=0;
scan();
delay_10ms(500);
i=0;
for(k=100;k>0;k--)
{
for(j=0;j<5;j++)
{
LEDD=i;
scan();
delay_1(k);
LEDD=0xffffffff;
scan();
delay_1(100-k);
}
}
LEDD=0xffffffff;
scan();
delay_10ms(200);
i=0;
for(k=0;k<100;k++)
{
for(j=0;j<5;j++)
{
LEDD=i;
scan();
delay_1(k);
LEDD=0xffffffff;
scan();
delay_1(100-k);
}
}
for(j=0;j<5;j++)
{
LEDD=0;
scan();
delay_10ms(50);
LEDD=0xffffffff;
scan();
delay_10ms(50);
}
}
void VOL_2()
{
uchar j,k;
ulong i;
for(k=1;k<50;k++)
{
i=0xfffffffb;
while(i>0xffd00000)
{
for(j=0;j<k;j++)
{
LEDD=0;
scan2();
delay_1(1);
LEDD=i;
scan2();
delay_1(10);
}
i=i*2+1;
}
}
for(k=20;k<80;k++)
{
i=0xffffffeb;
while(i>0xffd00000)
{
for(j=0;j<k;j++)
{
LEDD=0;
scan2();
delay_1(1);
LEDD=i;
scan2();
delay_1(10);
}
i=i*2+1;
}
}
for(k=40;k<120;k++)
{
i=0xffffffab;
while(i>0xff000000)
{
for(j=0;j<k;j++)
{
LEDD=0;
scan2();
delay_1(1);
LEDD=i;
scan2();
delay_1(10);
}
i=i*2+1;
}
k++;
}
for(k=70;k<140;k++)
{
i=0xfffffeab;
while(i>0xff000000)
{
for(j=0;j<k;j++)
{
LEDD=0;
scan2();
delay_1(1);
LEDD=i;
scan2();
delay_1(10);
}
i=i*2+1;
}
k++;
k++;
}
for(k=70;k<140;k++)
{
i=0xfffffaab;
while(i>0xff000000)
{
for(j=0;j<k;j++)
{
LEDD=0;
scan2();
delay_1(1);
LEDD=i;
scan2();
delay_1(10);
}
i=i*2+1;
}
k++;
k++;
k++;
}
for(k=70;k<140;k++)
{
i=0xffffeaab;
while(i>0xff000000)
{
for(j=0;j<k;j++)
{
LEDD=0;
scan2();
delay_1(1);
LEDD=i;
scan2();
delay_1(10);
}
i=i*2+1;
}
k++;
k++;
k++;
k++;
k++;
}
for(k=70;k<140;k++)
{
i=0xffffaaab;
while(i>0xff000000)
{
for(j=0;j<k;j++)
{
LEDD=0;
scan2();
delay_1(1);
LEDD=i;
scan2();
delay_1(10);
}
i=i*2+1;
}
k++;
k++;
k++;
k++;
k++;
k++;
}
for(k=70;k<140;k++)
{
i=0xfffeaaab;
while(i>0xff000000)
{
for(j=0;j<k;j++)
{
LEDD=0;
scan2();
delay_1(1);
LEDD=i;
scan2();
delay_1(10);
}
i=i*2+1;
}
k++;
k++;
k++;
k++;
k++;
k++;
k++;
}
for(k=70;k<140;k++)
{
i=0xfffaaaab;
while(i>0xff000000)
{
for(j=0;j<k;j++)
{
LEDD=0;
scan2();
delay_1(1);
LEDD=i;
scan2();
delay_1(10);
}
i=i*2+1;
}
k++;
}
for(k=70;k<140;k++)
{
i=0xffeaaaab;
while(i>0xff000000)
{
for(j=0;j<k;j++)
{
LEDD=0;
scan2();
delay_1(1);
LEDD=i;
scan2();
delay_1(10);
}
i=i*2+1;
}
k++;
k++;
k++;
k++;
k++;
k++;
k++;
k++;
}
for(k=70;k<140;k++)
{
i=0xffaaaaab;
while(i>0xff000000)
{
for(j=0;j<k;j++)
{
LEDD=0;
scan2();
delay_1(1);
LEDD=i;
scan2();
delay_1(10);
}
i=i*2+1;
}
k++;
k++;
k++;
k++;
k++;
k++;
k++;
k++;
k++;
}
for(k=140;k>10;k--)
{
i=0xffaaaaab;
while(i>0xff000000)
{
for(j=0;j<k;j++)
{
LEDD=0;
scan2();
delay_1(1);
LEDD=i;
scan2();
delay_1(10);
}
i=i*2+1;
}
k=k/9*8;
}
LEDD=0xffffffff;
scan2();
delay_10ms(150);
for(i=0;i<5;i++)
{
LEDD=0;
scan2();
delay_10ms(50);
for(k=100;k>0;k--)
{
for(j=0;j<5;j++)
{
LEDD=0;
scan2();
delay_1(k);
LEDD=0xffffffff;
scan2();
delay_1(100-k);
}
}
}
}
void VOL_3()
{
uchar j,k;
ulong i;
for(k=1;k<50;k++)
{
i=0xfffffffb;
while(i>0xffd00000)
{
for(j=0;j<k;j++)
{
LEDD=0;
scan();
delay_1(1);
LEDD=i;
scan();
delay_1(10);
}
i=i*2+1;
}
}
for(k=20;k<80;k++)
{
i=0xffffffeb;
while(i>0xffd00000)
{
for(j=0;j<k;j++)
{
LEDD=0;
scan();
delay_1(1);
LEDD=i;
scan();
delay_1(10);
}
i=i*2+1;
}
}
for(k=40;k<120;k++)
{
i=0xffffffab;
while(i>0xff000000)
{
for(j=0;j<k;j++)
{
LEDD=0;
scan();
delay_1(1);
LEDD=i;
scan();
delay_1(10);
}
i=i*2+1;
}
k++;
}
for(k=70;k<140;k++)
{
i=0xfffffeab;
while(i>0xff000000)
{
for(j=0;j<k;j++)
{
LEDD=0;
scan();
delay_1(1);
LEDD=i;
scan();
delay_1(10);
}
i=i*2+1;
}
k++;
k++;
}
for(k=70;k<140;k++)
{
i=0xfffffaab;
while(i>0xff000000)
{
for(j=0;j<k;j++)
{
LEDD=0;
scan();
delay_1(1);
LEDD=i;
scan();
delay_1(10);
}
i=i*2+1;
}
k++;
k++;
k++;
}
for(k=70;k<140;k++)
{
i=0xffffeaab;
while(i>0xff000000)
{
for(j=0;j<k;j++)
{
LEDD=0;
scan();
delay_1(1);
LEDD=i;
scan();
delay_1(10);
}
i=i*2+1;
}
k++;
k++;
k++;
k++;
k++;
}
for(k=70;k<140;k++)
{
i=0xffffaaab;
while(i>0xff000000)
{
for(j=0;j<k;j++)
{
LEDD=0;
scan();
delay_1(1);
LEDD=i;
scan();
delay_1(10);
}
i=i*2+1;
}
k++;
k++;
k++;
k++;
k++;
k++;
}
for(k=70;k<140;k++)
{
i=0xfffeaaab;
while(i>0xff000000)
{
for(j=0;j<k;j++)
{
LEDD=0;
scan();
delay_1(1);
LEDD=i;
scan();
delay_1(10);
}
i=i*2+1;
}
k++;
k++;
k++;
k++;
k++;
k++;
k++;
}
for(k=70;k<140;k++)
{
i=0xfffaaaab;
while(i>0xff000000)
{
for(j=0;j<k;j++)
{
LEDD=0;
scan();
delay_1(1);
LEDD=i;
scan();
delay_1(10);
}
i=i*2+1;
}
k++;
}
for(k=70;k<140;k++)
{
i=0xffeaaaab;
while(i>0xff000000)
{
for(j=0;j<k;j++)
{
LEDD=0;
scan();
delay_1(1);
LEDD=i;
scan();
delay_1(10);
}
i=i*2+1;
}
k++;
k++;
k++;
k++;
k++;
k++;
k++;
k++;
}
for(k=70;k<140;k++)
{
i=0xffaaaaab;
while(i>0xff000000)
{
for(j=0;j<k;j++)
{
LEDD=0;
scan();
delay_1(1);
LEDD=i;
scan();
delay_1(10);
}
i=i*2+1;
}
k++;
k++;
k++;
k++;
k++;
k++;
k++;
k++;
k++;
}
for(k=140;k>10;k--)
{
i=0xffaaaaab;
while(i>0xff000000)
{
for(j=0;j<k;j++)
{
LEDD=0;
scan();
delay_1(1);
LEDD=i;
scan();
delay_1(10);
}
i=i*2+1;
}
k=k/9*8;
}
LEDD=0xffffffff;
scan();
delay_10ms(150);
for(i=0;i<5;i++)
{
LEDD=0;
scan();
delay_10ms(50);
for(k=100;k>0;k--)
{
for(j=0;j<5;j++)
{
LEDD=0;
scan();
delay_1(k);
LEDD=0xffffffff;
scan();
delay_1(100-k);
}
}
}
}
void main()
{
while(1)
{
VOL_1();
VOL_2();
VOL_3();
}
}
谢谢哦!我是个菜鸟,慢慢学习.
一周热门 更多>