I am trying to multiplex a 4 digit - 7 segment display. The problem is the "next digit" is still faintly glowing the lit segments of the "previous digit".
My hardware works fine with the Multiplex7Seg library and example but I wanted to learn more about it and come up with something a little simpler.
After some internet research i came up with this:
The code I'm using is a variation of work done here:
http://paulm.com/inchoate/2008/03/arduino_showing_multiplexed_led_mat.html
int DIGIT_PINS[] = {10,11,12,13};
int SEG_PINS[] = {2,3,4,5,6,7,8};
byte PATTERN[5][4]=
{{B1111111,B0000000,B0000000,B0000000},//first part of pattern
{B1111111,B0000000,B0000000,B0000000},//The code is set up to show animations but all frames are identical for testing
{B1111111,B0000000,B0000000,B0000000},
{B1111111,B0000000,B0000000,B0000000},
{B1111111,B0000000,B0000000,B0000000}};//last part of pattern
#define DIGIT_COUNT (sizeof(DIGIT_PINS)/sizeof(DIGIT_PINS[0]))
#define SEG_COUNT (sizeof(SEG_PINS)/sizeof(SEG_PINS[0]))
#define PATTERN_SIZE (5);
#define PATTERN_DELAY (1);
void setup(){
int pinset=0;
Serial.begin(9600);
for (pinset=0; pinset<4; pinset++){
pinMode (DIGIT_PINS[pinset],OUTPUT);
}
for (pinset=0; pinset<7; pinset++){
pinMode (SEG_PINS[pinset],OUTPUT);
}
}
void loop(){
int pS = PATTERN_SIZE;
int pD = PATTERN_DELAY;
//int loopControl = 0;
for (int loopControl =0; loopControl <pS; loopControl++){
long start = millis();
while (millis() - start < pD){
DispOut(PATTERN[loopControl]);
}
}
}
void DispOut(byte currentPattern[]){
int pattern_index =0;
int last_digit=DIGIT_COUNT-1;
for (int digit_index = 0; digit_index < DIGIT_COUNT; last_digit=digit_index++){
digitalWrite(DIGIT_PINS[last_digit], LOW);
digitalWrite(DIGIT_PINS[digit_index], HIGH);
byte pat = currentPattern[pattern_index];
for (int seg_index = SEG_COUNT-1; seg_index >= 0; seg_index--, pat >>=1){
digitalWrite(SEG_PINS[seg_index], pat & 1 ? HIGH : LOW);
}
delay(3);
pattern_index++;
}
}
The hardware I am using (using 2N3904 transistors):
Any Ideas?