Jump to content
43oh

4 Digit 7 Segment Parallel (16 pins) Led Display Programming with Energia


Recommended Posts

Hello,

After some reading from master's tutorials i have made my 4 digit, 7segment Led display, working with MSP430,

I have used array definitions for digits and segments. Also i wrapped that within a function so that we can control the number and the digit we want to display.

Probably code can be improved a lot, but this is i could do for now. Recommendations are welcomed. And i will be glad if it helps for very beginner Launchpaders ))

 

PS: It is working allll parallel. i have used 7 output pins for segments and 4 output pins for the digits..

 

int segA = P1_3; int segB = P1_4; int segF = P1_5;int segG = P2_0;int segE = P2_1;int segC = P2_2;int segD = P2_3; int dig1=P1_7;int dig2=P1_6;int dig3=P2_5;int dig4=P2_4;byte seven_seg_digits[10][7] = { { 1,1,1,1,1,1,0 },  // = 0                                                           { 0,1,1,0,0,0,0 },  // = 1                                                           { 1,1,0,1,1,0,1 },  // = 2                                                           { 1,1,1,1,0,0,1 },  // = 3                                                           { 0,1,1,0,0,1,1 },  // = 4                                                           { 1,0,1,1,0,1,1 },  // = 5                                                           { 1,0,1,1,1,1,1 },  // = 6                                                           { 1,1,1,0,0,0,0 },  // = 7                                                           { 1,1,1,1,1,1,1 },  // = 8                                                           { 1,1,1,0,0,1,1 }   // = 9                                                           };                                                            byte four_digits[4][4]=  {{0,1,1,1},//ilk dijit a
Link to post
Share on other sites

On the above code we have made a function that lets us display the number (0-9) to the desired digit (1-4). Now, by using some modula (%) and little math. we are calculating each digits seperately in a (up to) four digit number (actually in a number that is between 0-9999)

//sirri.tanribilir@gmail.comint segA = P1_3; int segB = P1_4; int segF = P1_5; int segG = P2_0; int segE = P2_1; int segC = P2_2; int segD = P2_3; int dig1=P1_7;int dig2=P1_6;int dig3=P2_5;//int dig4=P2_4;int dig4=P1_2;long sayi;byte seven_seg_digits[10][7] = { { 1,1,1,1,1,1,0 },  // = 0                                                           { 0,1,1,0,0,0,0 },  // = 1                                                           { 1,1,0,1,1,0,1 },  // = 2                                                           { 1,1,1,1,0,0,1 },  // = 3                                                           { 0,1,1,0,0,1,1 },  // = 4                                                           { 1,0,1,1,0,1,1 },  // = 5                                                           { 1,0,1,1,1,1,1 },  // = 6                                                           { 1,1,1,0,0,0,0 },  // = 7                                                           { 1,1,1,1,1,1,1 },  // = 8                                                           { 1,1,1,0,0,1,1 }   // = 9                                                           };                                                            byte four_digits[4][4]=  {{0,1,1,1},//ilk dijit a
Link to post
Share on other sites

Nice work!

 

A couple of questions...

  • What kind of display do you use?
  • Any specific value for the resistors?

...and a couple of ideas!

  • You could also program to display the a b c d e f values, so you'll get an hexadecimal display!

If I'm correct, 

//
// . a .
// f   b
// . g .
// e   c
// . d .
// 
// a b c d e f g segment
 { 1,1,1,1,1,0,1 },  // = a
 { 0,0,1,1,1,1,1 },  // = b
 { 0,0,0,1,1,0,1 },  // = c
 { 0,1,1,1,1,0,1 },  // = d
 { 1,0,0,1,1,1,1 },  // = e
 { 1,0,0,0,1,1,1 },  // = f
  • Instead of using the serial port (pins P1_1 and P1_2), you can use the I2C port.

You just need to free pins P1_6 = SCL and P1_7 = SDA and use instead P2_6 and P2_7, if the quartz isn't soldered. 

 

Enjoy  ;-)

Link to post
Share on other sites

Hi Vilo. Thanks for your comments. I will improve this a little bit more and as you say i will add some letters as well. Indeed i want to make an RTC clock with its alarm and some LED's. Anyway, i am using 4 digits 7 segment LED display with 16 pins. It writes KRUPS-6605 on the display, i guess that is the label ) I did not use any transistor for driving the LED segments. The brightness is not very good because of that. I have used 470 ohm resistors for the segment inputs.

You are right about the P1_2 pin. I have changed it.

 

What i want to improve is, in order to have more pins available, i guess i will need an 7 segment encoder. That will decrease my used pin to 4 instead of 7 (And also 4 more pins for the digit selection, it makes 8 pins occupied-- Right now it is 11 ! :/ )

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...