#include<reg52.h>
#define led P1
void led_liang(unsigned int i);
void led_an(unsigned int i);
void Delay(unsigned int t);
void main()
{
led_an(0);
led_liang(1);
led_an(1);
led_liang(2);
led_an(2);
led_liang(3);
led_an(3);
led_liang(4);
led_an(4);
led_liang(5);
led_an(5);
led_liang(6);
led_an(6);
led_liang(7);
led_an(7);
}
void led_liang(unsigned int i)
{
unsigned int CYCLE=300,PWM_LOW=0;
unsigned int j;
led=0xff;
Delay(30000) ;
led=0xfe;
for(j=0;j<i;j++)
{
led<<=1;
led|=0x01 ;
}
for(PWM_LOW=1;PWM_LOW<CYCLE;PWM_LOW++)
{ unsigned char temp;
led=led;
temp=led;
Delay(PWM_LOW);
led=led|(~led);
Delay(CYCLE-PWM_LOW);
led=led&temp;
}
}
void led_an(unsigned int i)
{
unsigned int CYCLE=300,PWM_LOW=0;
unsigned int j;
unsigned int t;
led=0xfe;
for(j=0;j<i;j++)
{
led<<=1;
led|=0x01 ;
}
for(PWM_LOW=CYCLE-1;PWM_LOW>0;PWM_LOW--)
{ unsigned char temp;
unsigned char temp1;
temp=led;
temp1=t;
Delay(PWM_LOW);
led=led|(~led);
Delay(CYCLE-PWM_LOW);
led=led&temp;
} }
void Delay(unsigned int t)
{
while(--t);
} |