#include<reg51.h>
void delay0_1s()
{
unsigned char i;
for(i=0;i<0x0a;i++){
TH1=(65536-10000)/256;
TL1=(65536-10000)%256;
TR1=1;
while(!TF1);
TF1=0; }
}
void delay_t(unsigned char t)
{
unsigned char g;
for(g=0;g<t;g++)delay0_1s();
}
void main()
{
unsigned char j, w ,i, k;
TMOD=0x10;
while(1){
w=0x01;
for(j=0;j<8;j++){
P1=~w;
w<<=1;
delay_t(2);}
for(i=0;i<3;i++)
{
P1=0xff;delay_t(5);
P1=0x00;delay_t(5);
}
}}
|