#include
#define uchar unsigned char
sbit key1=P1^0;
sbit key2=P1^1;
sbit key3=P1^2;
sbit key4=P1^3;
uchar LED=0xfe;
void delay(uchar a)
{
uchar i,j;
for(i=0;ifor(j=0;j<120;j++);
}
main()
{
P0=0xff;
while(1)
{
while(key1==0){P0=0x00;delay(200);P0=0xff;delay(200)}
while(key2==0){P0=0xff;}
while(key3==0){P0=LED;LED=(LED<<1)|0x01;if(LED==0xff)LED=0xfe;delay(200);}
while(key4==0){P0=LED;LED=(LED>>1)|0x80;if(LED==0xff)LED=0x7f;delay(200);}
}
}
上图,没图不好写。
给你做proteus仿真吗?
还是要实物?