|
#include<reg52.h>
sbit led1=P0^0;
sbit led2=P0^1;
sbit key1=P2^0;
sbit key2=P2^1;
sbit key3=P2^2;
sbit key4=P2^3;
sbit key5=P2^4;
void delay()
{
unsigned int a=30000;
while(a--);
}
void main()
{
while(1)
{
if(key1==0)
{
if(key2!=0)
{
if(key3==0)
{
led1=~led1;
delay();
}
else if(key4==0)
{
led1=1;
led2=0;
}
else if(key5==0)
{
led1=0;
led2=1;
}
}
}
}
}
你把引脚改了试试这个呢 |
|