#include <msp430.h> int main(void) { WDTCTL=WDTPW+WDTHOLD; P1DIR |= BIT0; P1REN |= BIT1; P1OUT |= BIT1; while (1) { if(P1IN & BIT1) { P1OUT |= BIT0; } // Stop watchdog timer P1DIR |= BIT0; // 使P1.0工作在输出模式 // 使P1.1设置上拉电阻 // 判断P1.1输入电平 // P1.0输出为高电平else { P1OUT &= ~BIT0; // P1.0输出为低电平 } } }