I am still new to the Launchpad and so far I can get a LED to blink, so now I want to control that LED by having it turn on or off( don’t care at this point :p) when I press a button(switch 2). However the button always seems to show as being pressed. I have Googled tons and found some examples but none of them seem to work, It seems I have the newer version of the Launchpad and I need a pullup or down resistor. I read the datasheet and I have tried adding the code for the pull up resistor but I don’t think I did it right. I have included the code below I hope someone can point me in the right direction or point out my errors
Thanks in Advance.
Chris
#include <msp430g2553.h> // For the M430G2553 chip, void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer P1REN |= 0x08; //Turn on PullUp on????? How do you turn it off? P1DIR &= ~BIT3; // Push Port 1 P1.3 (push button) as input //P1OUT &= 0x08; // Pull down resistor??? P1DIR |= BIT6; // Set P1.6 (LED) to output direction P1SEL &= ~(BIT3 | BIT6); // Select Port 1 P1.3 (push button) P1OUT &= ~BIT6; // Set the LED off int value = P1IN & BIT3; while( 1 ) { if( value == 0) // Push button down when bit 3 == 0 P1OUT |= BIT6; // Set LED on when button down else P1OUT &= ~BIT6; // Set LED off when button off } }