LED Patterns Using Msp430 Launchpad
by msminhas93 in Circuits > Microcontrollers
10907 Views, 12 Favorites, 0 Comments
LED Patterns Using Msp430 Launchpad
This is a simple micro-controller program in which we make led's glow in various attractive patterns using msp430 launchpad. I found that there are many instructables on arduino but very few are existing for msp430, although msp430 can be used without launchpad directly on breadboard or on PCB. So I thought of encouraging people to use Texas Instruments msp430 launchpad. This is my first instructable, hope you find it helpful and interesting.
This is the you tube link of the final product's video.
http://www.youtube.com/watch?feature=player_detailpage&v=g9NRDXL0vOk
This is the you tube link of the final product's video.
http://www.youtube.com/watch?feature=player_detailpage&v=g9NRDXL0vOk
Downloads
Components Required
RGB LED 2 pin (8)
1k resistors (8)
Berg wires F-F (9)
male headers (9)
preset 4.7k (1)[optional if you are not trying to power the chip without launchpad]
copper clad - if you want to make you own PCB
1k resistors (8)
Berg wires F-F (9)
male headers (9)
preset 4.7k (1)[optional if you are not trying to power the chip without launchpad]
copper clad - if you want to make you own PCB
The C Code
I am using TI code composer studio v5.4 for buring the code onto the chip. I've written the code in C language and not assembly language.
Steps to make project in CCS:
1)Run code composer studio.
2)Select new->project
3)Select css project in the dialogue box that appears
4) Since I am using msp430g2231 I have selected that ic from the list you can choose whichever ic you intend to use. Give the project a suitable name. You have to select an empty project with main.c else you'll have to manually add c file which is not that difficult but I won't be covering that in this list.
5)Make your project as active project by clicking on it in the project explorer.
6) Expand your current project by clicking on the small plus on the folder. Then double click on the main.c to open the file.
7) Copy paste the code given in the next step into the main.c and save it.
8)Further steps are shown in the images.
Steps to make project in CCS:
1)Run code composer studio.
2)Select new->project
3)Select css project in the dialogue box that appears
4) Since I am using msp430g2231 I have selected that ic from the list you can choose whichever ic you intend to use. Give the project a suitable name. You have to select an empty project with main.c else you'll have to manually add c file which is not that difficult but I won't be covering that in this list.
5)Make your project as active project by clicking on it in the project explorer.
6) Expand your current project by clicking on the small plus on the folder. Then double click on the main.c to open the file.
7) Copy paste the code given in the next step into the main.c and save it.
8)Further steps are shown in the images.
Code
#include <msp430g2231.h>
main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
P1DIR |= 0XFF;
int x = 0X01;
long i=0;
int j=1;
int k=0;
int l=0;
for(;;)
{
for(k=1;k<=5;k++){
x=0x01;
for(j=1;j<=8;j++){
P1OUT = x;
x*=2;
for(i=0;i<=10000;i++)
{
}
}
}
for(k=1;k<=5;k++){
x=0x80;
for(j=1;j<=8;j++){
P1OUT = x;
x/=2;
for(i=0;i<=10000;i++)
{
}
}
}
for(k=1;k<=5;k++){
P1OUT=0xAA;
for(l=0;l<=1;l++){
for(i=0;i<=64000;i++)
{}}
P1OUT=0x55;
for(l=0;l<=1;l++){
for(i=0;i<=64000;i++)
{}}
}
for(k=1;k<=5;k++){
P1OUT=0x18;
for(i=0;i<=20000;i++)
{}
P1OUT=0x24;
for(i=0;i<=20000;i++)
{}
P1OUT=0x42;
for(i=0;i<=20000;i++)
{}
P1OUT=0x81;
for(i=0;i<=20000;i++)
{}
}
for(k=1;k<=5;k++){
P1OUT=0x81;
for(i=0;i<=20000;i++)
{}
P1OUT=0x42;
for(i=0;i<=20000;i++)
{}
P1OUT=0x24;
for(i=0;i<=20000;i++)
{}
P1OUT=0x18;
for(i=0;i<=20000;i++)
{}
}
}
}
main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
P1DIR |= 0XFF;
int x = 0X01;
long i=0;
int j=1;
int k=0;
int l=0;
for(;;)
{
for(k=1;k<=5;k++){
x=0x01;
for(j=1;j<=8;j++){
P1OUT = x;
x*=2;
for(i=0;i<=10000;i++)
{
}
}
}
for(k=1;k<=5;k++){
x=0x80;
for(j=1;j<=8;j++){
P1OUT = x;
x/=2;
for(i=0;i<=10000;i++)
{
}
}
}
for(k=1;k<=5;k++){
P1OUT=0xAA;
for(l=0;l<=1;l++){
for(i=0;i<=64000;i++)
{}}
P1OUT=0x55;
for(l=0;l<=1;l++){
for(i=0;i<=64000;i++)
{}}
}
for(k=1;k<=5;k++){
P1OUT=0x18;
for(i=0;i<=20000;i++)
{}
P1OUT=0x24;
for(i=0;i<=20000;i++)
{}
P1OUT=0x42;
for(i=0;i<=20000;i++)
{}
P1OUT=0x81;
for(i=0;i<=20000;i++)
{}
}
for(k=1;k<=5;k++){
P1OUT=0x81;
for(i=0;i<=20000;i++)
{}
P1OUT=0x42;
for(i=0;i<=20000;i++)
{}
P1OUT=0x24;
for(i=0;i<=20000;i++)
{}
P1OUT=0x18;
for(i=0;i<=20000;i++)
{}
}
}
}
Circuit Diagram
The circuit diagram shown below is what you need to do. You can do it on a breadboard if you want.
PCB Layout
If anyone of you is interested in making a PCB, I've made the layout for you. But in this instructable I won't be teaching how to make a PCB.
That would be all. If you have any doubts feel free to ask me. I'll try my best to clear it. Thank you for reading this instructable.
P.S: If you are interested in msp430 launchpad, I've started a blog http://learningmsp430.wordpress.com/ where I'll posting whatever I learn regarding the controller. So please do visit and see it.
That would be all. If you have any doubts feel free to ask me. I'll try my best to clear it. Thank you for reading this instructable.
P.S: If you are interested in msp430 launchpad, I've started a blog http://learningmsp430.wordpress.com/ where I'll posting whatever I learn regarding the controller. So please do visit and see it.