zigbee技术实现按键控制led(中断方式)

zigbee技术实现按键控制led中断方式

#include

#define LED1 P1_0
#define LED2 P1_1
#define LED3 P0_4

#define KEY1 P0_1
#define KEY2 P2_0
void Delay(void);
void main(void){
P0SEL&=~0x12;
P1SEL&=~0x03;
P2SEL&=~0x01;

P0DIR|=0x10;
P1DIR|=0x03;

LED1=0;
LED2=0;
LED3=0;

P0IFG|=0x00;
P0INP|=0x02;
P0IEN|=0x02;
IEN1|=0x20;
PICTL|=0x02;

P2IFG|=0x00;
P2INP|=0x01;
P2IEN|=0x01;
IEN2|=0x02;
PICTL|=0x08;

EA=1;
Delay();
while(1){
LED3=1;
Delay();
LED3=0;
Delay();

}

}
void Delay(void)
{
unsigned int i,j;
for(i=0;i<1000;i++){
for(j=0;j<50;j++){
asm(“NOP”);
asm(“NOP”);
asm(“NOP”);
}
}
}

#pragma vector=P0INT_VECTOR
__interrupt void P0ISR(void)
{
if(P0IFG>0)
{
Delay();
if(P0_1==0){
while(!P0_1);
P0IFG=0;
LED1=!LED1;
}
}
P0IF&=0;
}

#pragma vector=P2INT_VECTOR
__interrupt void P2ISR(void)
{
if(P2IFG>0)
{
Delay();
if(P2_0==0){
while(!P2_0);
P2IFG=0;
LED2=!LED2;
}
}
P2IF&=0;
}
op=>operation: 我的操作
cond=>condition: 确认?

st->op->cond
cond(yes)->e
cond(no)->op


- 

你可能感兴趣的:(zigbee技术实现按键控制led(中断方式))