This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Turning Launchpad LED on and off with Button Switch S2

Other Parts Discussed in Thread: MSP430G2553

I am very new at learning to program the MSP430. Using Code Composer Studio v5, I am working on turning the Launchpad LEDs on and off with switch S2 with the MSP430G2553.

I borrowed the following program from the TI Wiki, but all that happens when I run the program after Debug is that the red LED illuminates and remains lit even when I push S2.

Can anyone tell me what am I doing wrong? Why does the red LED even illuminate when the "if" routine is supposed to tell it to do so only when S2 is pushed? Is the P1DIR |= 0x01 expression actually causing the LED to illuminate

You can see that I have some very basic questions.

The program can be found at  http://processors.wiki.ti.com/index.php/MSP430_LaunchPad_Interrupt_vs_Polling

Thanks in advance,

Earle

#include <msp430g2553.h>

void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1DIR |= 0x01; // Set P1.0 to output direction

while (1) // Infinite Loop
{
if ((BIT3 & P1IN)) // active low switch
{
P1OUT &= ~0x01; // if P1.3 is 1(not pressed),reset P1.0
}else
{
P1OUT |= 0x01; // else set P1.0
}
}
}

**Attention** This is a public forum