#include<STC8H.H>
sbit led_a =P2^4;
sbit led_b =P2^3;
sbit led_c =P4^6;
sbit led_d =P7^7;
sbit led_e =P7^6;
sbit led_f =P2^6;
sbit led_g =P2^7;
sbit led_dp =P0^0;
sbit led_11 =P4^5;
sbit led_12 =P2^5;
unsigned char code led[]={
0x3F,0x06,0x5B,0x4F,0x66,0x6D,
0x7D,0x07,0x7F,0x6F}; // 0~9
void yanshi();
void main()
{
unsigned char xianshi_a1;
unsigned char a1;
P0M0 |=1<<0;
P0M1 &=1<<0;
P2M0 |=(1<<5)+(1<<4)+(1<<3)+(1<<6)+(1<<7);
P2M1 &=~((1<<5)+(1<<4)+(1<<3)+(1<<6)+(1<<7));
P4M0 |=(1<<6)+(1<<5);
P4M1 &=~((1<<6)+(1<<5));
P7M0 |=(1<<7)+(1<<6);
P7M1 &=~((1<<7)+(1<<6));
led_11=1;
led_12=1;
a1=0;
while(1)
{
yanshi();
xianshi_a1=led[a1];
if(xianshi_a1&(1<<0)){led_a=0;}else{led_a=1;}
if(xianshi_a1&(1<<1)){led_b=0;}else{led_b=1;}
if(xianshi_a1&(1<<2)){led_c=0;}else{led_c=1;}
if(xianshi_a1&(1<<3)){led_d=0;}else{led_d=1;}
if(xianshi_a1&(1<<4)){led_e=0;}else{led_e=1;}
if(xianshi_a1&(1<<5)){led_f=0;}else{led_f=1;}
if(xianshi_a1&(1<<6)){led_g=0;}else{led_g=1;}
if(xianshi_a1&(1<<7)){led_dp=0;}else{led_dp=1;}
a1++;
if(a1==10){a1=0;}
}
}
void yanshi()
{
unsigned int y;
unsigned char z;
for(y=800;y>0;y--)
for(z=200;z>0;z--);
}
|