sapna.dudani@gmail.com
Member level 4
hey friends... can any one please help me to write a source code for driving a 4 digit seven segment led display using msp430g2xx series and also i have to scroll the digits automatically......
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
const unsigned char Lookup[10] = {} // Make a table with segments for each digit
unsigned char Values[4] = {1, 2, 3, 4}; // Digit display values
// set up one port as a output connected to the segments
P1DIR = 0xFF;
// set up a second port as a output connected to the LED commons -- you'll need to buffer the pin with a transistor or FET. Lowest 4 bits drive the LED common pins
P2DIR = 0xFF;
for (i=0; i<4; i++) {
P2OUT = 1 << i; // Enable digit drive i
P1OUT = Lookup[Values[i]]; // Display segments for digit i
// add a delay to slow the refresh
}
no i dont have any schematic .....
i am a beginner in c i have tried to write a program to drive a 4 digit seven segment led display using msp430g2231 and display BALL now i want to scroll the digits , the program i have written just to display the four digits is
#include<msp430g2231.h>
void delay_ms(unsigned int i)
{
int j,a;
for(a=0; a<=i; a++)
for(j=0; j<=100; j++);
}
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
P1DIR = 0XFF;
P2SEL = 0X3F;
P2DIR = 0XC0;
for(;
{
P2OUT = 0X00;
P1OUT = 0XFF;
delay_ms(5);
P2OUT = 0X40;
P1OUT = 0XFD;
delay_ms(5);
P2OUT = 0X80;
P1OUT = 0X43;
delay_ms(5);
P2OUT = 0XC0;
P1OUT = 0X43;
delay_ms(5);
}
}
now how do ii scroll these digits....
unsigned char digits[5] = {0xFF, 0xFD, 0x43, 0x43, BLANK}; // BLANK is pattern for all segments off
unsigned char temp;
for (;;) {
// adjust the n delay (multiple of 20mS) for scrolling speed
for (i=0; i<n; i++) {
P2OUT = 0X00;
P1OUT = digits[0];
delay_ms(5);
P2OUT = 0X40;
P1OUT = digits[1];
delay_ms(5);
P2OUT = 0X80;
P1OUT = digits[2];
delay_ms(5);
P2OUT = 0XC0;
P1OUT = digits[3];
delay_ms(5);
}
// scroll the digits
temp = digits[0];
digits[0] = digits[1];
digits[1] = digits[2];
digits[3] = digits[4];
digits[4] = temp;
}