/* 程序功能:一键多功能控 */
#include <reg52.h>
#include <intrins.h>
unsigned char set ;
sbit key =P3^2;
void key_k1();
void delayms(unsigned int ms)
{
unsigned char k;
while (ms--)
{
for(k=100;k>0;k--);
}
}
void main (void )
{
unsigned char i,f,g;
P0=0xfe;
while (1)
{
if(key==0)key_k1();
{
switch (set)
case 1:
for(i=7;i>0;i--)
{
P0=_crol_(P0,1);
delayms(500);
break;
}
case 2:
for(f=7;f>0;f--)
{
P0=_cror_(P0,1);
delayms(500);
break;
}
case 3:
P0=0xf0;
break;
default:
P0=0xff;
break;
}
}
}
void key_k1()
{
if(key==0)++set;
if(set>=4)set=0;
F0:if(key==0)goto F0;
}
编译通不过 |