Electronics - MSP430 - Switching on a LED with a breadboard

In this MSP430 tutorial we will see how to use the LaunchPad to switch on a LED with a breadboard.

It's an easy tutorial for beginners. Simple, easy and useful.

You can watch the result of the tutorial directly with the video below:

What we need to achieve this tutorial

For our example, we need:

  • one MSP430 LaunchPad board
  • one or two breadboards
  • two wires
  • one resistor (150 ohms)
  • one LED

We could do this tutorial without any resistor, but it's a good practice to use one and it always reduce the current through the LED.


I turn back the MSP430 board because I wanted to plug the headers inside breadboards.

It is, indeed, a good way to never directly touch headers of the LaunchPad.

I plugged the resistor with the P1.4 pin.
It's the 6th from the top of the board and on the left side (check the video for more detail).

Then I linked the negative end of the resistor to the anode (the most long side) of the LED.

The cathode is linked with the black wire that I plugged to the GND of the board (the first pin on the top right).

That's it.

We are now ready to code the software.

The code

The code is quite easy, we don't even need a while loop.

In the following code 0x10 is an hexadecimal number equals to 0010000 in binary.

We have to set it like that because we would like to turn on the P1.4 pin which is the 5th on the list.

And 0x10 is exactly the way to set the pin to 1 in the register.

Notice that BIT4 is a define equals to 0x10 (this value is present in the include at the top of the file).

#include <msp430.h>

int main(void) {
    WDTCTL = WDTPW | WDTHOLD;     // Stop watchdog timer
    P1DIR &= 0x00;                // reseting the P1DIR register
    P1OUT &= 0x00;                // reseting the P1OUT register

    P1DIR |= BIT4;                // setting the P1DIR register to 0x10
    P1OUT |= BIT4;                // setting the P1OUT register to 0x10

    return 0;


A great way to learn electronics especially with the MSP430 LaunchPad.
Easy to reproduce!

Congratulations, you've just made it. laugh



Thanks for your grateful informations, am working in development company india so it will be helpful info for my works.


Thanks a lot for sharing.

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Refresh Type the characters you see in this picture. Type the characters you see in the picture; if you can't read them, submit the form and a new image will be generated. Not case sensitive.  Switch to audio verification.