Pages

Saturday, 12 October 2013

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:
YouTube Video:
http://www.youtube.com/watch?v=g9NRDXL0vOk
Note: If anyone wants the PCB file, just let me know.

No comments:

Post a Comment