#include <Library/LunchboxCommon.
h>
#include <msp430.h>
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#define SW BIT3 // Switch -> P1.3 (On-board Switch, Pull-Up
configuration)
#define LED BIT6 // Red LED -> P1.6 (On-Board LED, Active High
Configuration)
#define LED BIT5 // Red LED -> P1.5 (On-Board LED, Active High
Configuration)
#define LED BIT4 // Red LED -> P1.4 (On-Board LED, Active High
Configuration)
/*@brief entry point for the code*/
void main(void)
{
WDTCTL = WDTPW | WDTHOLD; //! Stop Watchdog (Not recommended for code in
production and devices working in field)
initialise_SerialPrint_on_lunchbox(); // a function
int x = 0;
P1DIR |= LED; // Set LED pin -> Output
P1DIR &= ~SW; // Set SW pin -> Input
while(1)
{
if(!(P1IN & SW)) // If SW is Pressed
{
__delay_cycle(20000);
while(!(P1IN & SW));
__delay_cycle(20000);
P1OUT ^= LED1; // Toggle LED
}
if(!(P1IN & SW)) // If SW is Pressed
{
__delay_cycle(20000);
while(!(P1IN & SW));
__delay_cycle(20000);
P1OUT ^= LED2; // Toggle LED
if(!(P1IN & SW)) // If SW is Pressed
{
__delay_cycle(20000);
while(!(P1IN & SW));
__delay_cycle(20000);
P1OUT ^= LED3; // Toggle LED
}
}
}