Led patterns using msp430g2231

led-patterns
This application is generation of led patterns using msp430g2231.
Components Required:
msp430g2231 (1)
1k resistors (8)
preset 4.7k (1)
rgb led 2pin (8)
berg wires (8/9)
toggle switch(1)
705009_RB_00_FB.EPS_1000

Theory:
In this application we utilize all 8 ports of the micro-controller. Each port is connected to one of the led’s via current limiting resistors. Now all we need to do is set all the ports as output and then change the patterns by varying the port pins that are high/low. We are using code composer studio for this. The program is written in c. We can either use the launchpad directly for connections via breadboard or we can make a PCB for it. The advantage of PCB is that you can carry is with you without having to take the launchpad as well your laptop with you. Or you can build a shield/booster pack of led’s like in the image shown below.

021020131203

Code:
#include
main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
P1DIR |= 0XFF; // set all the ports as output ports
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++)
{}

}

}
}

My instructable link:

http://www.instructables.com/id/LED-patterns-using-msp430-launchpad/

YouTube Video:
http://www.youtube.com/watch?v=g9NRDXL0vOk

Note: If anyone wants the PCB file, just let me know.

Advertisements

12 thoughts on “Led patterns using msp430g2231

  1. Hi!

    I also use the MSP 430 for my Projects. I am a beginner too, but one Thing i have learned. Loops and delays are not good. For timekeeping Jobs you always should use timer Interrupts. If you dont know how this works, i might write a tutorial for this. It is really important to learn it now, before you are starting bigger Projects. The microcontroller you have Chosen is the most powersaving in the world, and you can use this powersaving for battery powered Projects, or just to save our Environment. You will like that, timer interrupts are great.
    If you Need examples and a tutorial for it, just tell it to me.

    Kind regards, Steffen

    • Thank you very much for reading and giving valuable feedback. You are absolutely right about software delays. I really haven’t learnt how to initialize the timer part and manipulate it yet. It would be nice if you could share your knowledge with me.
      Regards, Manpreet Singh

      • I have finished my blog entry about the Timer Interrupts.
        It is also really helpful to write that down. It helps me too to understand it. I would recommend to write down what you have learned.

        You can find my Blogentry here:

        http://www.tns-labs.org/msp430-using-timer-interrupts-instead-of-delays/

        This page is the page of our electronics Group. We are three People at the Moment and we use MSP430 and Arduino, my part is the MSP.

        I am not always as fast as this time with writing down tutorials. πŸ™‚

      • There are other samples about timers too, and many other stuff in the ti example section. I have made an Alarm clock for me with the MSP430 using an external Crystal, and a seven Segment display. This works really well. And i made a wordclock based on the Alarm clock code.

      • I myself was thinking of making a digital clock. Once I make it I’ll share it on the blog and then you’ll get one more perspective on clocks πŸ˜€

  2. I have a lot of ideas but i am slow in developing. I read that you are able to code in Assembler. Are you able to explain it on the MSP430 step by step as a tutorial? Assembler would be my next big Thing.

    • I’ll definitely make one on assembly language but it’ll take time since I’ve learnt how to write assembly language program in IAR workbench and CCS directives are totally different. I’ll try to make a tutorial as soon as possible.

    • Ground refers to a lower electric potential. As you know in order for current to flow it needs a path. Now when you make a circuit on paper you normally connect all the wires right and don’t let the remain floating. In the same way on breadboard you choose one of the horizontal lines as ground then connect all the cathodes to it. Also if you are interconnecting two different circuits a common ground is required. This is so that zero potential will be equalized in this way. So a relative 5V in your circuit will be same as 5V potential difference w.r.t ground if you have a common ground. Else these potential differences may or may not be same. That is why you do common ground. So just take the ground from your launchpad and connect it to the breadboard along with all the other cathodes.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s