LED Blinking Example
Download and Install Software
We have finally come to a stage we can write the code for LED blinking. Here is the code that blink the LED on the launchpad.
#include <msp430g2553.h> // Tutorial LED Blinking from referencedesigner.com // We will use the msp430g255 microcontroller that comes with the launchpad unsigned int i = 0; void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer. // Turn off the watchdog timer, otherwise your device will reset. We will learn about it later. // P1DIR is configures the port pin as an output or an input. If it is 1 it is Output. P1DIR = P1DIR | 0x01; // We could also write P1DIR = 0x01 P1OUT = 0x01; // Turn the LED off for (;;) // Infinite loop { if ( (P1OUT & 0x01) == 1) P1OUT = 0x00; else P1OUT = 0x01; for(i=0; i< 20000; i++); // This creates a delay. } }
|
The best way to learn about the LED blinking would be to take a look at the youtube. Make sure you do not miss anything in the option.