|
#include"reg52.h"
#include<intrins.h>
#define IO_IN P1
#define IO_OUT P0
unsigned char LightData=0x11;
void Delay_Ms(unsigned int time)
{
unsigned char i;
while(time--)
{
for(i=0;i<120;i++);
}
}
void operate()
{
unsigned char temp;
IO_IN=0X0F;
temp=IO_IN&0x0F;
switch(temp)
{
case 0x00:
IO_OUT=0x0F;
break;
case 0x01:
IO_OUT=0x00;
break;
case 0x02:
LightData=_crol_(LightData,1);
IO_OUT=~LightData;
Delay_Ms(1000);
break;
case 0x03:
LightData=_cror_(LightData,1);
IO_OUT=~LightData;
Delay_Ms(1000);
break;
default:
IO_OUT=temp;
break;
}
}
void main()
{
while(1)
{
operate();
}
}
|
|