I am trying to write a code that allows an LED to blink 5 times and stop, after pressing a button. I have successfully written a code to make the LED respond to the button press and will include it below. My question is how do I make a subroutine to add to the program to cake the LED blink multiple times upon button press.
#include <msp430.h>
#define button1 0x0003 //This defines pin1 of port 1
#define DEVELOPMENT 0x5A80
#define ENABLE_RED 0xFFFE
#define RED_OFF 0x00FE
#define RED 0x0001
#define value (P1IN & button1)
#define LIGHT 0x0003
------------------------------------------------------------------------------
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
PM5CTL0 = ENABLE_RED;
P1DIR = RED; //This defines P1.0 (LED) as an output and P1.1 (S1) as an input
P1REN = button1;
P1OUT = button1;
while (1)
{
if (value == 0)
P1OUT = LIGHT;
else
P1OUT = RED_OFF;
}
}