#include "reg52.h"
typedef unsigned int u16;
typedef unsigned int u8;
sbit LSA=P2^2;
sbit LSB=P2^3;
sbit LSC=P2^4;
unsigned char code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07};
void delay(u16 i){
while(i--);
}
void everyItem(){
u8 i;
for (i=0;i<8;i++){
P0=table[i];
delay(12000);
}
}
void Led(){
u8 i;
for (i=0;i<8;i++){
P0=0;//用于清除影响
switch(i){
case(0):
LSA=1;LSB=1;LSC=1;everyItem(); break;
case(1):
LSA=0;LSB=1;LSC=1;everyItem(); break;
case(2):
LSA=1;LSB=0;LSC=1;everyItem(); break;
case(3):
LSA=0;LSB=0;LSC=1;everyItem(); break;
case(4):
LSA=1;LSB=1;LSC=0;everyItem(); break;
case(5):
LSA=0;LSB=1;LSC=0;everyItem(); break;
case(6):
LSA=1;LSB=0;LSC=0;everyItem(); break;
case(7):
LSA=0;LSB=0;LSC=0;everyItem(); break;
}
}
}
void main(){
while(1){
Led();
}
}