Jump to content
43oh

Green 7-segment LED modules


Recommended Posts

  • 2 months later...

Hey guys, I found another 7-digit module like the one above. One difference though, this one is ORANGE! post-2374-135135522788_thumb.jpg

 

And here is a simple program I used to test it:

#include "MSP430G2252.h"

#define NUM0 0x3F
#define NUM1 0x06
#define NUM2 0x5B
#define NUM3 0x4F
#define NUM4 0x66
#define NUM5 0x6D
#define NUM6 0x7D
#define NUM7 0x07
#define NUM8 0x7F
#define NUM9 0x6F

int NUMBER=0;

char DIGI[7] = {NUM0,NUM1,NUM2,NUM3,NUM4,NUM5,NUM6};
const char BIT[8] = {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};

int DIGIT=0;
int c = 0;
void main( void ){
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
BCSCTL1 = CALBC1_1MHZ;
DCOCTL = CALDCO_1MHZ;

 	P1OUT = 0x7F;
P1DIR = 0x7F;
   P2SEL = 0x00;   	// allow 2.6-2.7 to output
P2OUT = 0x7F;
P2DIR = 0x7F;
P1IES = BIT7;
   P1IFG = 0;
   P1IE = BIT7;
P2IES = BIT7;
   P2IFG = 0;
   P2IE = BIT7;
__enable_interrupt();

for(;{
	P2OUT = ~BIT[c];
 		P1OUT = DIGI[c];
	__delay_cycles(50);
 		P1OUT = 0x00;
	c++;
	if(c == 7) c = 0;
}
}

#pragma vector=PORT1_VECTOR
__interrupt void PORT1_ISR(void)
{
NUMBER++;
if(NUMBER == 10)
	NUMBER = 0;
switch (NUMBER){
case 0:
	DIGI[DIGIT] = NUM0;
	break;
case 1:
	DIGI[DIGIT] = NUM1;
	break;
case 2:
	DIGI[DIGIT] = NUM2;
	break;
case 3:
	DIGI[DIGIT] = NUM3;
	break;
case 4:
	DIGI[DIGIT] = NUM4;
	break;
case 5:
	DIGI[DIGIT] = NUM5;
	break;
case 6:
	DIGI[DIGIT] = NUM6;
	break;
case 7:
	DIGI[DIGIT] = NUM7;
	break;
case 8:
	DIGI[DIGIT] = NUM8;
	break;
case 9:
	DIGI[DIGIT] = NUM9;
	break;
}
P1IFG &= ~BIT7;
}

#pragma vector=PORT2_VECTOR
__interrupt void PORT2_ISR(void)
{
DIGIT++;
if(DIGIT == 7)
	DIGIT = 0;
P2IFG &= ~BIT7;
}

post-2374-135135522804_thumb.jpg

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...