msp430g2553按键控制LED灯

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

/*按键同时控制两盏灯*/#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;}

1 / 2
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功