如下程序怎么循环运行3次?
#include<reg52.h>
sbit key0=P1^0;
sbit key1=P1^1;
sbit key2=P1^2;
sbit key3=P1^3;
sbit key4=P1^4;
sbit key5=P1^5;
sbit key6=P1^6;
sbit key7=P1^7;
sbit key8=P3^0;
sbit key9=P3^1;
sbit key10=P3^2;
sbit ssr1=P2^0;
sbit ssr2=P2^1;
sbit ssr3=P2^2;
sbit ssr4=P2^3;
sbit ssr5=P2^4;
sbit ssr6=P2^5;
sbit ssr7=P2^6;
sbit ssr8=P2^7;
void main ()
{
P1=0xff;
P2=0xff;
while(1)
{
if(P1==0xfe)
P2=0xfd;
else
P2=0xff;
if(P1==0xfa)
P2=0xfc;
else
P2=0xff;
if(P1==0xff)
P2=0xfc;
else
P2=0xff;
if(P1==0xfd)
P2=0xfe;
else
P2=0xff;
}
}
|