|
//運(yùn)用if else if ele的語句來完成發(fā)光程序
#include<reg51.h>
#define uint unsigned int//定義uint為無符號整型
#define uchar unsigned char//是表示之后代碼中的“uchar”全部代表“unsigned char”
void main(void)
{
uchar i;
while (1)
{
i=P2;
if(i==0xff) P1=~i;
else if(i==0xfe) P1=0xfe;
else if(i==0xf0) P1=0xf0;
else if(i==0x55) P1=0x55;
else if(i==0xaa) P1=0xaa;
else P1=0xff;
}
}
|
|