display's segment still blinkink when off !

hey guys,
after wiring the whole thing (display + shift register (74HC594) + resistors + capacitor) and uploaded the script, when trying to display 0, the g segment of the display is still blinking a little bit and all other that should be off in any pattern and doesn’t fully go off so what do you think might be the problem here ? i guess it should be a hardware and not in the software but here is the script in case :
and this link to a video displaying the problem : http://www.youtube.com/watch?v=3G__8nn1mvE&feature=youtu.be

i am sure that the display is fine because i tested it many time alone again and again when posting this and it worked fine

//16 is clock
//15 is latch
// 14 is data


//these pins for the gear number display
int latchPin0 = 15;
int clockPin0 = 16;
int dataPin0 = 14;

byte gearDisplay = 0;
void setup()
{
pinMode(latchPin0, OUTPUT);
pinMode(dataPin0, OUTPUT);
pinMode(clockPin0, OUTPUT);
digitalWrite(latchPin0, LOW);
digitalWrite(dataPin0, LOW);
digitalWrite(clockPin0, LOW);
}

void loop()
{
gearDisplay = 0b00000011;
updateShiftRegister();


}
void updateShiftRegister()
{
  digitalWrite(latchPin0, LOW);
  shiftOut(dataPin0, clockPin0, LSBFIRST, gearDisplay);
  digitalWrite(latchPin0, HIGH);
}

void updateShiftRegister()
{
  shiftOut(dataPin0, clockPin0, LSBFIRST, gearDisplay);
  digitalWrite(latchPin0, HIGH);
  digitalWrite(latchPin0, LOW);
}

still the same problem
do you think the capacitor is the problem ? because i used this 594 before with the same circuit but with no capacitor and it worked fine back then

firashelou:
still the same problem

You noticed that I changed the order of your LatchPin0 operations?

firashelou:
do you think the capacitor is the problem ? because i used this 594 before with the same circuit but with no capacitor and it worked fine back then

It's across the power pins - no issue.
But, remove it and see.

If you change your Loop

void loop()
{
  gearDisplay = 0b00000011;
  updateShiftRegister();
  delay (200);
}

it won't constantly update the register and data clocking through, if that is what is happening, shouldn't get on the outputs repeatedly so.

Still, the datasheet shows that
with the low-to-high transition on Pin12 (== your Latchpin0?) "Transfer shift register data to storage register and outputs Qn."
So, to me, as data is shifted in none of it should be transferred to the outputs till Pin12 gets pulsed (initially it is LOW, so it gets sent HIGH and back LOW)

http://www.nxp.com/documents/data_sheet/74HC_HCT594.pdf

exactly right, when i added the delay as you said it looks like fine then it start to blink every segment by turn all the 7 segments, so what do you think ?

Your schematic doesn't indicate how or which '594 control pins (11,12,14) are connected to the Arduino. Can you clarify?

Also, Copy and Paste directly from the IDE the "misbehaving" sketch as current.

ok the 11 is clock, 12 is latch, 14 is data

here is my sketch :

//16 is clock
//15 is latch
// 14 is data


//these pins for the gear number display
int latchPin0 = 15;
int clockPin0 = 16;
int dataPin0 = 14;

byte gearDisplay;

void setup()
{
pinMode(latchPin0, OUTPUT);
pinMode(dataPin0, OUTPUT);
pinMode(clockPin0, OUTPUT);

}

void loop()
{
gearDisplay = 0b01100001;
updateShiftRegister();
delay(200);


}
void updateShiftRegister()
{
  digitalWrite(latchPin0, LOW);
  shiftOut(dataPin0, clockPin0, LSBFIRST, gearDisplay);
  digitalWrite(latchPin0, HIGH);
  
  
}

Copy and Paste the following into a New sketch

int latchPin0 = 15;
int clockPin0 = 16;
int dataPin0 = 14;

byte gearDisplay;

void setup()
{
  pinMode(latchPin0,OUTPUT);
  digitalWrite (latchPin0,LOW);
  pinMode(dataPin0,OUTPUT);
  digitalWrite (dataPin0,LOW);
  pinMode(clockPin0,OUTPUT);
  digitalWrite (clockPin0,LOW);
}

void loop()
{
  gearDisplay = 0b01100001;
  updateShiftRegister();
}

void updateShiftRegister()
{
  shiftOut(dataPin0, clockPin0, LSBFIRST, gearDisplay);
  digitalWrite(latchPin0, HIGH);
  digitalWrite(latchPin0, LOW);
}

cirrected digitalWrite formatting, spaces

i tried it and didn't work :S still the same as the video
the delay thing is working but for a period of time because after that a segment will go on or off
from experiencing with the codes it seems that it's a code matter because i changed the ic to 595 and changed some pin and same results

i can't get back how i did programed this segment without any problems before :S

RP when i added these codes to the other 2 digits (2 segment , 4 digits), everything seems to work fine !!
so any idea why ? tomorrow i will write the full code with buttons to see if it keeps the good results
here are my full codes so far :

//Project

//first display
byte datapin = 2;
byte clockpin = 3;
byte latchpin = 4;

//second display
byte datapin2 = 7;
byte clockpin2 = 8;
byte latchpin2 = 9;

//third display
byte First = 5;
byte Second = 6;
byte Third = 10;
byte Fourth = 11;

//these pins for the gear number display
int latchPin0 = 15;
int clockPin0 = 16;
int dataPin0 = 14;

byte gearDisplay = 0;

//Gear Box display segment
byte GearBoxSegments[10] = { 0b0010101, //0 - 0
                             0b10000110, //1 - 1
                             0b00000111, //2 - 2
                             0b10101111, //3 - 3
                             0b11001111, //4 - 4
                             0b10000011, //5 - 5
                             0b11000000, //6 - 6
                             0b11100011, //7 - 7
                             0b11010101, //8 - 8
                             0b11000111, //9 - 9
                           };

int times;
byte segments[12] = {0b00101011, //n - 0
                     0b10000110, //E - 1
                     0b00000111, //t - 2
                     0b10101111, //r - 3
                     0b11001111, //l - 4
                     0b10000011, //b - 5
                     0b11000000, //O - 6
                     0b11100011, //u - 7
                     0b11010101, //v - 8
                     0b11000111, //L - 9
                     0b11101111, //i - 10
                     0b11101010  //M - 11
                   };
                     

byte FirstDigit;
byte SecondDigit;
byte ThirdDigit;
byte FourthDigit;

byte FirstD;
byte SecondD;
byte ThirdD;
byte FourthD;

void setup ()
{
  pinMode(latchPin0, OUTPUT);
  pinMode(dataPin0, OUTPUT);
  pinMode(clockPin0, OUTPUT);
  
  pinMode(Second,OUTPUT);
  digitalWrite(Second,HIGH);
  pinMode(First,OUTPUT);
  digitalWrite(First,HIGH);
  pinMode(datapin,OUTPUT);
  digitalWrite(datapin,LOW);
  pinMode(latchpin,OUTPUT);
  digitalWrite(latchpin,LOW);
  pinMode(clockpin,OUTPUT);
  digitalWrite(clockpin,LOW);
  
  pinMode(Fourth,OUTPUT);
  digitalWrite(Fourth,HIGH);
  pinMode(Third,OUTPUT);
  digitalWrite(Third,HIGH);
  pinMode(datapin2,OUTPUT);
  digitalWrite(datapin2,LOW);
  pinMode(latchpin2,OUTPUT);
  digitalWrite(latchpin2,LOW);
  pinMode(clockpin2,OUTPUT);
  digitalWrite(clockpin2,LOW);
  
}

void loop ()
{
  FirstD = 12; //this will give me 0, this is second digit
  SecondD = 12; //this will give me 1, this is actully the first digit
  ThirdD = 36; //this is the fourth digit
  FourthD = 26; // this is third digit
  
  digitparse();
  lookitup();
  
  gearDisplay = 0b00001101;
  updateShiftRegister();
  //delay(500);
  
  

}   

void latchit ()
{
  digitalWrite(latchpin,HIGH);
  digitalWrite(latchpin,LOW);
  digitalWrite(latchpin2,HIGH);
  digitalWrite(latchpin2,LOW);
}

void digitparse ()
{
  //from left to right
  FirstDigit = FirstD / 12;
  SecondDigit = SecondD % 12;
  ThirdDigit = ThirdD / 12;  
  FourthDigit = FourthD % 12;   
}

void lookitup ()
{
  shiftOut(datapin,clockpin,MSBFIRST,segments[FirstDigit]);
  shiftOut(datapin,clockpin,MSBFIRST,segments[SecondDigit]);
  shiftOut(datapin2,clockpin2,MSBFIRST,segments[ThirdDigit]);
  shiftOut(datapin2,clockpin2,MSBFIRST,segments[FourthDigit]);
  latchit();
  dispOn();    
}

void dispOn ()
{
  for(times=0; times < 100; times++) // display interval
  {
    digitalWrite(Second,LOW);
    delay(5);
    digitalWrite(Second,HIGH);
    digitalWrite(First,LOW);
    delay(5);
    digitalWrite(First,HIGH);
    
    digitalWrite(Third,LOW);
    delay(5);
    digitalWrite(Third,HIGH);
    digitalWrite(Fourth,LOW);
    delay(5);
    digitalWrite(Fourth,HIGH);
  }
}

void updateShiftRegister()
{
  
  shiftOut(dataPin0, clockPin0, LSBFIRST, gearDisplay);
  digitalWrite(latchPin0, LOW);  
  digitalWrite(latchPin0, HIGH);
  
}

What happens with this (following)?
[N.B. I didn’t “forget” anything, I need a results report.]

int latchPin0 = 15;
int clockPin0 = 16;
int dataPin0 = 14;

byte gearDisplay;
int cycle;

void setup()
{
  pinMode(latchPin0,OUTPUT);
  digitalWrite (latchPin0,LOW);
  pinMode(dataPin0,OUTPUT);
  digitalWrite (dataPin0,LOW);
  pinMode(clockPin0,OUTPUT);
  digitalWrite (clockPin0,LOW);
}

void loop()
{
  for (cycle=0; cycle<10000; cycle++)
  {
    gearDisplay = 0b111111111;
    shiftOut(dataPin0, clockPin0, LSBFIRST, gearDisplay);  
  }
  for (cycle=0; cycle<10000; cycle++)
  {
    gearDisplay = 0b00000000;
    shiftOut(dataPin0, clockPin0, LSBFIRST, gearDisplay);  
  }  
}

firashelou:
it seems that it’s a code matter because i changed the ic to 595 and changed some pin and same results

That’s desperation. Stop it.

firashelou:
RP when i added these codes to the other 2 digits (2 segment , 4 digits), everything seems to work fine !!

I’m not sure what you mean.
Maybe you have another “breadboarding problem”.

no there is no breadboard here it's a circuit that i've beeb wiring since the 2 digits segment display
what I meant is that this single digit display and the other 2 display of 2 digits each will be controlled by one arduino, so the last script I posted is the full script which I am working on, so when I added the small script of this post to the other big one, the single digit display stoped the bad results in the video and ghe blinking and it seems to be solved!
so any idea why?

firashelou:
so any idea why?

There is a period where it is doing the dispOn().
That is equivalent to having a delay().

When the sketch in question was only about constantly pumping data to the '594, over and over, then there was the issue with the undesired dim segment. Introducing a delay() tamed that issue.
Still, I think that the data shifted in should not appear at the outputs till the "latch" gets pulsed.

ah ok and about the last part yes you're right i don't know why that problem is happening
many thanks RP