#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit LED1=P0^0;
sbit LED2=P0^1;
sbit LED3=P0^2;
sbit K1=P1^0;
sbit K2=P1^1;
sbit K3=P1^2;
void delayms (uint ms)
{
uchar i;
while (ms--)
{
for (i=130;i>0;i--);
}
}
void mian (void )
{
uchar flag=1;
P0=0XFF;
P1=0XFF;
while(1)
{
LED1=K1;
LED2=K2;
if((K3==0)&&flag)
{
LED3=~LED3;
flag=0;
}
else if(K3==1)
{
flag=1;
}
}
}
刚学单片机不久,只知道下升沿的触方式, |