MSP430G2452按鍵控制P1.0口LED燈亮滅
#include "msp430g2452.h"
本文引用地址:http://m.butianyuan.cn/article/201611/323655.htmvoid main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1DIR = 0x01; // P1.0 output, else input
P1OUT = 0x08; // P1.3 set, else reset
P1REN |= 0x08; // P1.3 pullup
while (1) // Test P1.3
{
if(0x08 & P1IN)
{
P1OUT |= 0x01; // if P1.3 set, set P1.0
}
else P1OUT &= ~0x01; // else reset
}
}
評(píng)論