Need help to blink the led1(red) 5times only when switch1 button is pressed. This is far what ive got. Thanks!
#include <msp430g2553.h>
unsigned int i;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1DIR |= 0x01; // Set P1.0 to output direction
P1OUT &=~(0x01); Off
P1REN=0x08; //Enable interal pull up resistors
P1IE |= 0x08; // P1.3 interrupt enabled
P1IES |= 0x08; // P1.3 Hi/lo edge
P1IFG &= ~0x08; // P1.3 IFG cleared
_BIS_SR(GIE); // General Interrupt Enable
while(1){ //Loop - Do nothing
if (i>0)
{
P1OUT ^=0x01;
__delay_cycles(500000);
}
}
}
// Port 1 interrupt service routine
#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
i^ =0x01;
P1IFG &= ~0x08; // P1.3 IFG cleared
P1OUT &=~(0x01); //Clear the LEDs so they start in OFF state
}