/*按键同时控制两盏灯*/#includemsp430g2553.hvoidInit_Port(){P1DIR|=BIT0+BIT6;P1DIR&=~BIT3;P1REN|=BIT3;P1IE|=BIT3;P1OUT&=~BIT0;P1OUT|=BIT6;}voidmain(void){WDTCTL=WDTPW+WDTHOLD;Init_Port();_EINT();while(1);}#pragmavector=PORT1_VECTOR__interruptvoidPort(void){unsignedcharPushKey;unsignedinti;PushKey=P1IFG&BIT3;for(i=0;i50000;i++);if(!(P1IN&BIT3)==PushKey){P1IFG=0;return;}if(PushKey&BIT3){P1OUT^=BIT0;P1OUT^=BIT6;}P1IFG=0;return;}/*按键控制一盏灯*/#includemsp430g2553.hvoidInit_Port(){P1DIR|=BIT0;P1DIR&=~BIT3;P1REN|=BIT3;P1IE|=BIT3;P1OUT&=~BIT0;}voidmain(void){WDTCTL=WDTPW+WDTHOLD;Init_Port();_EINT();while(1);}#pragmavector=PORT1_VECTOR__interruptvoidPort(void){unsignedcharPushKey;unsignedinti;PushKey=P1IFG&BIT3;for(i=0;i50000;i++);if(!(P1IN&BIT3)==PushKey){P1IFG&=~BIT3;return;}if(PushKey&BIT3){P1OUT^=BIT0;}P1IFG&=~BIT3;return;}