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:
For our example, we need:
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 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.
Comments
Srk (not verified)
Thursday, May 2, 2013 - 8:46am
Permalink
Thanks for your grateful
Thanks for your grateful informations, am working in development company india so it will be helpful info for my works.
HSUR (not verified)
Sunday, November 10, 2013 - 8:58pm
Permalink
Thanks a lot for sharing.
Thanks a lot for sharing.
Great teacher (not verified)
Wednesday, February 21, 2018 - 7:21pm
Permalink
Thank you for explaining
Thank you for explaining everything, very helpful!
Add new comment