Interfacing a 7 Segment Display using TI Launchpad

As part of learning programming msp430 in TI Launchpad,just tried out to interface a seven segment display using the launchpad.I used a common cathode seven segment display.To know a bit more about 7 segment display http://en.wikipedia.org/wiki/Seven-segment_display

As a quick intro,a 7 segment display has 8 segments of which 7 segments are numbered A to G and one segment is a dot(Decimal point).

In this experiment all i did was to display the numbers 1 to 9 and then 0 in a 7 segment display.For that we’ve to connect each o/p of the msp430 to the 7 pins of the display.

the code for the same is

1
#include<msp430.h>
2
//delay function
3
void delay()
4
{
5
  for(long int j=100000;j!=0;j--);
6
  P1OUT=0x00;
7
}
8
void main()
9
{
10
  while(1)//infinite loop
11
  {
12
    P1DIR|=0xFF;//all port1 pins are output
13
    P1OUT=0;//initialise output to 0
14
    P1OUT=BIT1|BIT2;//light led b n c(1)
15
    delay();
16
    P1OUT=BIT0|BIT1|BIT6|BIT4|BIT3;//light a b g e d(2)
17
    delay();
18
    P1OUT=BIT0|BIT1|BIT6|BIT2|BIT3;//to show 3
19
    delay();
20
    P1OUT=BIT5|BIT6|BIT2;//4
21
    delay();
22
    P1OUT=BIT0|BIT5|BIT6|BIT2|BIT3;//5
23
    delay();
24
    P1OUT=BIT0|BIT5|BIT4|BIT3|BIT2|BIT6;//6
25
    delay();
26
    P1OUT=BIT0|BIT1|BIT2;//7
27
    delay();
28
    P1OUT|=0xFF;//8
29
    delay();
30
    P1OUT=BIT6|BIT5|BIT0|BIT1|BIT2|BIT3;//9
31
    delay();
32
    P1OUT|=(0xFF&(~(1<<6)));//0
33
    delay();
34
  }
35
}

And th outputof my code is in the following video

Advertisements

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