SparkFun Forums 

Where electronics enthusiasts find answers.

#205699
Hi all,
I'm attempting to recreate the countup timer on the Sparkfun website with my Arduino but I'm having issues. I've purchase the large digit drivers and the 6.5" seven segment displays. It appears that any time my leading digit is a 1 or 4, the following digits go haywire.
I've tried it with three digits as well, and still, same problem. To visualize, if I create a counter from 0 to 999 with three digits 000-099 work, 200-399 work, and 500-999 work, but the 100's and 400's display odd segments including the dp.
If you guys can provide any assistance, it would be greatly appreciated.... I'm really going crazy over here.
Thanks!
-Mc
#205743
Hi Mc,

That's a pretty weird issue here. Just to confirm it is not a code issue, have you tried using our Two-Digit Example Code from the Hookup Guide? If not, give that a try. Also, I'm not familiar with the tutorial you are following, can you provide a link to that in case there is a problem with the code in that tutorial?
#205744
Give this code a try and see if it works for you. It originally drove a 4 digit display but I've modified it so that it should drive a three digit display.

Code: Select all
/* 
/* 
   Four daisy Chained Shift Registers that create a 4 digit counter.
   74HC595 connected to 7-Segment LED display. The bit order corrosponds to the SparkFun Large Digit Driver
   but feel free to rearange your bits if you use a different order.
*/

int dataPin = 7;
int latchPin = 5;
int clockPin = 6;

// Segment letter in a 7 segment display:      HBCDEGFA
// Digit to display:       0          1          2           3          4           5           6           7           8           9
// Hex value:             0x7B       0x60       0x5D        0x75       0x66        0x37        0x3F        0x61        0x7F        0x77
byte dec_digits[] = {0b01111011, 0b01100000, 0b01011101, 0b01110101, 0b01100110, 0b00110111, 0b00111111, 0b01100001, 0b01111111, 0b01110111 };
// 0b means binary, 0 is off, 1 is on. We're turning on and off different segments here to create numbers on the display.

void setup() {
  //set pins to output so you can control the shift register
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
}

void loop() {
 // for (int thousandsColumn = 0; thousandsColumn < 10; thousandsColumn++) {  //First digit  (Xnnn)
    for (int hundredsColumn = 0; hundredsColumn < 10; hundredsColumn++) {   //Second digit (nXnn)
      for (int tensColumn = 0; tensColumn < 10; tensColumn++) {             //Third digit  (nnXn)
        for (int onesColumn = 0; onesColumn < 10; onesColumn++) {           //Fourth digit (nnnX)
          
          // take the latchPin low so
          // the LEDs don't change while you're sending in bits:
          digitalWrite(latchPin, LOW);
          
          // shift out the bits:
          shiftOut(dataPin, clockPin, MSBFIRST, dec_digits[onesColumn]);      //Write out first digit 
          shiftOut(dataPin, clockPin, MSBFIRST, dec_digits[tensColumn]);      //Write out second digit
          shiftOut(dataPin, clockPin, MSBFIRST, dec_digits[hundredsColumn]);  //Write out third digit
//          shiftOut(dataPin, clockPin, MSBFIRST, dec_digits[thousandsColumn]); //Write out fourth digit
          
          //take the latch pin high so the LEDs will light up:
          digitalWrite(latchPin, HIGH);
          
          // pause before next value:
          delay(100);
        }
      }
    }
//  }
}
#205752
TS-Mark wrote: Wed Jul 10, 2019 3:15 pm

That's a pretty weird issue here. Just to confirm it is not a code issue, have you tried using our Two-Digit Example Code from the Hookup Guide? If not, give that a try. Also, I'm not familiar with the tutorial you are following, can you provide a link to that in case there is a problem with the code in that tutorial?
Yeah, no kidding. I'm absolutely baffled. I'm using the two digit example you've provided, modified to use with an added digit. If I remove a digit from the chain, and use the two digit example posted above, the leading digit still does not work and has the same problem.
-Mc
#205754
Sorry for the last reply Chris. It's been a long day. I see now how it is supposed to increment.

I've discovered that the program as you sent it, counts the time between resets on the Arduino. It does this as a multiple of 10... 1 second represents a 10 count, 10 seconds represents a 100 count and most importantly... it displays the digits correctly.

Now, if I can modify it to work off of a Runtime variable I have... I'll be set!
#205770
TS-Chris wrote: Wed Jul 10, 2019 3:24 pm Give this code a try and see if it works for you. It originally drove a 4 digit display but I've modified it so that it should drive a three digit display.
Hi Chris,
It appears to be working, but I can't get it to display the digits while running. I have to hit the reset button to send it to the digits. What am I doing wrong?
Mc
#205933
Thanks for all your help Chris.
I found that the board has a dead pin. Must have done something to it while experimenting. Anywho, changed the pins and now your code works perfectly!!!

Can you give me some advice on blanking the digits (turning all off)?