Problems with multiseg displays and shift registers *Solved*

Hi there, so I've been playing with one of these sparkfun 4 digit/7 segment displays for a couple days now. And well the things fun, but its a bit needy on pins, so im trying to adapt it to run off of a shift register (74HC595 register specifically). I had been running into a problem yesterday where what was happening was the numbers were getting transposed over a digit. This had been because in my code, i was turning on a new digit without shutting the last one off and updating the shift reg. (like dig 1 would show 4, 2 would show 1, 3 would show 2 and 4 would show 3. However upon close inspection, 1 was dimly lit with 1, 2 was dimly 2, 3 was 3 and 4 was 4).

I tackled the code a bit and am trying to shut off things quick enough. and well currently, the screen shows up with the proper numbers in the proper places, however each digit is extremely dim (basically useless) I can get it brighter by dropping down a few resistor sizes, but im pretty sure bad things will happen if i go down that route.

Currently I'm still trying different fixes that come to my mins, but if anyone might have some insight on how to help me, it would be greatly appreciated.

So for the basic segments of code I have

void setup() 
{
  pinMode(datapin, OUTPUT); //datapin is the SER pin on the shift reg
  digitalWrite(datapin, LOW);
  pinMode(clockpin, OUTPUT);// clock is serclk
  digitalWrite(clockpin, LOW);
  pinMode(output, OUTPUT);// output is the rclk pin
  digitalWrite(output, LOW);
  pinMode(enable, OUTPUT); // enable is the OE pin (which is actually tied to GND, i was experimenting with controlling it directly)
  digitalWrite(enable, HIGH);
  pinMode(dig1, OUTPUT); //these are pins 2,3,4,5 which when held high, will turn that digit of the screen on, and low will shut it off
  pinMode(dig2, OUTPUT);
  pinMode(dig3, OUTPUT);
  pinMode(dig4, OUTPUT);
  digitalWrite(dig1, LOW);
  digitalWrite(dig2, LOW);
  digitalWrite(dig3, LOW);
  digitalWrite(dig4, LOW);
}
void printnumb(char digit) 
{
  digitalWrite(output, LOW);  // put the output low so in a min i can pull it high and output the new batch of pinmodes
  switch(digit)
  {
  case '0':  
    shiftOut(datapin, clockpin, LSBFIRST, B00000011);  // basic shiftout for each of the different number (and letter) cases
    break;
  case '1':
    shiftOut(datapin, clockpin, LSBFIRST, B10011111);
    break;
// goes on to 9
  }
  digitalWrite(output, HIGH); // when thrown high, updates the output of the shift reg, and screen lights up
}

void convert(int y) //reason for the char in the first switch case was because ill also be displaying a -,C,H and rdy on the screen. 
//So this here is to convert the incoming int into the char needed.
{
  switch(y)
  {
  case 0:
    printnumb('0'); // in each case, call the function form above for each specific case
    break;
// on through 9 aswell
  }
}

void digit1(int x)
{
  digitalWrite(dig1, LOW); // shut off all the digits, so that i dont accidentally get a number from 1 of the other digits showign up on the wrong spot
  digitalWrite(dig2, LOW);
  digitalWrite(dig3, LOW);
  digitalWrite(dig4, LOW);
  convert(x); // but the int from later code into the converter to "make" the char needed, guess i could really skip the converter 
    //and just go straight from int to the shiftout, don't feel like it though.
  digitalWrite(dig1, HIGH); // turn this digit on with the shift reg's current output, and it should 
}
// theres another one for dig 2 3 and 4.


void loop()
{
digit1(1);
digit2(2);
digit3(3);
digit4(4);
}

however each digit is extremely dim

So the important thing is to find out why. Can you post a schematic to show how you have wired it up? You might have something wrong.

dang no camera.

Hmm, well SR A-H are hooked up to A-H respectively on the display.
the common for digits 1-4 are hooked to digital pins 2-5 respectively on the arduino. This connection is made in series through a 1k resistor atm.
The datasheet for the display says that it has a 20mA forward current with a peak forward current of 30mA. I realise it should probably be that each of A-H should probably have a 250ohm resistor (5/250=20mA) but i dont have that many resistors, loads of 1ks(from work) but only like 3 330s and a couple 220s from a mostly used up book (im gonna have to buy another).

then for the rest of the connections. VCC and GND on shift reg are at 5V and gnd. OE is tied to gnd (i had been told on IRC that it shoudl be held low) and SRCLR is held at 5v. SER is plugged into digital 9 (datapin), SERCLK is plugged into digital 8 (clockpin), and RCLK is plugged to digital 10 (output)

ill post a schematic later when i've got a scanner nearby to scan it with.

I don't see the code letting the digits stay on for any determined length of time, you blast thru them all one after the other.
Try adding a check to see if 5mS or so have gone by and then call the up the next digit to be displayed, something like this:

digit_num = 1;
void loop(){

if ( (millis() - lastmillis)>=5){
lastmillis = lastmillis +5;
digit(digit_num);
digit_num = digit_num + 1;
if (digit_num == 5){digit_num = 1;}
 }
// do other stuff while waiting for 5mS to pass
}

A 7 segment display should be multiplexed in a very similar way to a matrix.
This page talks about what you need to do to refresh a matrix.
http://www.thebox.myzen.co.uk/Workshop/LED_Matrix.html

K thanks guys, actually it was mostly the delay thing (ended up putting a 3ms delay, 5ms had this odd subtle flashing look, but only if you saw it out of the corner of your eye, god only knows why, I'm not an optometrist).

perhaps after i go and work out a bit more of the bugs from this i might try and make it into a library to run one of these screens off a the arduino/a shift reg, or off a pair of shift registers, cause next im going to make 8 digits total work. Though my boss wants me to see just how many displays can be run off of an arduino in a shift register fashion, before it becomes ineffective, i've seen a few 256 LED matrixes so far, so thats up to 32 digits+decimal points. Doubt you'd ever need to run more then that off an arduino at any time ever, even with my bosses crazy phantasies for things to have me build.

well thx for the help, off to find the next problem to ask about.

Ok your next problem is to do it without using the delay function. That will allow you to do more with the processor.