#include <REG2051.H>
sbit led=P1^0;
sbit k1=P1^6;
sbit k2=P1^7;
void delay(unsigned char ms)
{
unsigned char x,y;
for(x=0;x<ms;x++)
for(y=0;y<50;y++);
}
void main()
{
unsigned char i,a=10,b=1;
k1=1;
k2=1;
led=1;
while(1)
{
led=0;
delay(a);
led=1;
delay(b);
if(k1==0)
delay(5);
if(k1==0)
{
while(!k1);
a++;
b--;
}
if(k2==0)
delay(5);
if(k2==0)
{
while(!k2);
a--;
b++;
}
if(a>9)
a=10;
if(b<2)
b=1;
}
}
sbit led=P1^0;
sbit k1=P1^6;
sbit k2=P1^7;
void delay(unsigned char ms)
{
unsigned char x,y;
for(x=0;x<ms;x++)
for(y=0;y<50;y++);
}
void main()
{
unsigned char i,a=10,b=1;
k1=1;
k2=1;
led=1;
while(1)
{
led=0;
delay(a);
led=1;
delay(b);
if(k1==0)
delay(5);
if(k1==0)
{
while(!k1);
a++;
b--;
}
if(k2==0)
delay(5);
if(k2==0)
{
while(!k2);
a--;
b++;
}
if(a>9)
a=10;
if(b<2)
b=1;
}
}
200字以内,仅用于支线交流,主线讨论请采用回复功能。