- #include<reg52.h>
- sbit LED8 = P0^7;
- sbit LED1 = P0^0;
- sbit LED7 = P0^6;
- sbit LED2 = P0^1;
- sbit LED6 = P0^5;
- sbit LED3 = P0^2;
- sbit LED5 = P0^4;
- sbit LED4 = P0^3;
- sbit ADDR0 = P1^0;
- sbit ADDR1 = P1^1;
- sbit ADDR2 = P1^2;
- sbit ADDR3 = P1^3;
- sbit ENLED = P1^4;
- void delay1()
- {
- int i,j;
- for(i=0;i<200;i++)
- for(j=0;j<200;j++)
- ;
-
- }
- void main()
- {
- int i=0,j=0,an[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80},
- bn[]={0xFE,0xFD,0xFB,0xF7,0xEF,0xDF,0xBF,0x7F};
- ADDR2 = 1;
- ADDR1 = 1;
- ADDR0 = 0;
- ADDR3 = 1;
- ENLED = 0;
-
-
- while(1)
- {
- i=0;
- P0 = 0x00;//1 quanshang
- while(i<=8)
- {
- P0 = ~P0;
- delay1();
- i++;
- }
-
- P0=0xFF;//1
- i=0;
- while(i<=7)
- {LED8 = ~LED8;
- LED1 = ~LED1;
- delay1();
-
- i++;
- }
- i=0;
- while(i<=5)
- { LED7 = ~LED7;
-
- LED2 = ~LED2;
- delay1();
- i++;
- }
- i=0;
- while(i<=3)
- {LED6 = ~LED6;
-
- LED3 = ~LED3;
- delay1();
- i++;
- }
- i=0;
- while(i<=3)
- {
- LED4=~LED4;
-
- LED5=~LED5;
- delay1();
- i++;
- }
-
- i=0;P0 = 0xF0; //2
- while(i<=9)
- {
- P0 = ~P0;
- delay1();
- i++;
- }
-
- P0=0xFF;//1
- i=0;
- while(i<=7)
- {LED8 = ~LED8;
- delay1();
- LED1 = ~LED1;
-
- i++;
- }
- i=0;
- while(i<=5)
- { LED7 = ~LED7;
- delay1();
- LED2 = ~LED2;
-
- i++;
- }
- i=0;
- while(i<=3)
- {LED6 = ~LED6;
- delay1();
- LED3 = ~LED3;
-
- i++;
- }
- i=0;
- while(i<=3)
- {
- LED4=~LED4;
- delay1();
- LED5=~LED5;
- i++;
- }
- i=0;
-
- P0=0x00;//3 quanyoushang
- while(i<8)
- {
- P0 = an[i];i++;
- delay1();
-
- }
- i--;
- while(i>=0)
- {
- P0 = an[i];i--;
- delay1();
- }
-
- P0=0x00;
- delay1();
- delay1(); //2 YAOSHANGKAISHI
- i=0;
- while(i<=7)
- {LED8 = ~LED8;
- delay1();
- LED1 = ~LED1;
-
- i++;
- }
- i=0;
- while(i<=5)
- { LED7 = ~LED7;
- delay1();
- LED2 = ~LED2;
-
- i++;
- }
- i=0;
- while(i<=3)
- {LED6 = ~LED6;
- delay1();
- LED3 = ~LED3;
-
- i++;
- }
- i=0;
- while(i<=3)
- {
- LED4=~LED4;
- delay1();
- LED5=~LED5;
- i++;
- }
- i=0;
-
- while(i<8) //4 youshang
- {
- P0 = bn[i];i++;
- delay1();
-
- }
- i--;
- while(i>=0)
- {
- P0 = bn[i];i--;
- delay1();
- }
-
- P0=0xFF; //2 SHUANGSHANGKAISHI
- delay1();
- delay1();
- P0=0x00;
- i=0;
- while(i<=7)
- {LED8 = ~LED8;
- LED1 = ~LED1;
- delay1();
-
- i++;
- }
- i=0;
- while(i<=5)
- { LED7 = ~LED7;
-
- LED2 = ~LED2;
- delay1();
- i++;
- }
- i=0;
- while(i<=3)
- {LED6 = ~LED6;
-
- LED3 = ~LED3;
- delay1();
- i++;
- }
- i=0;
- while(i<=3)
- {
- LED4=~LED4;
-
- LED5=~LED5;
- delay1();
- i++;
- }
- }
- }
复制代码 |