Let's Make Robots!

74hc595 with 7 segment dispaly not working right

For some reason I can't get my 7 segment dispaly and 74hc595 shift register to work right on my arduino.  I can get the segment to turn on one at a time.  When I try to do numbers it just doesn't work right?  I have clock pin, and data pin to the the arduino. It will try to light up my numbers but will be missing some segments. It will also skip numbers completely for example try to show 1, 4, and 6 and skip the rest. I tried putting a 0.1 cap on the latch also.  I have 220 resister running from each pin of the display to the shift register.  Here my code:

#define data 12
#define clock 8

byte zero =  B11111100;
byte one =   B01100000;
byte two =   B11011010;
byte three = B11110010;
byte four =  B01100110;
byte five =  B10110110;
byte six =   B00111110;
byte seven = B11100000;


void setup()
{
  pinMode(clock, OUTPUT); // make the clock pin an output
  pinMode(data , OUTPUT); // make the data pin an output3
}

void loop()
{
  shiftOut(data, clock, LSBFIRST, zero);
  delay(500);
  shiftOut(data, clock, LSBFIRST, one);
  delay(500);
  shiftOut(data, clock, LSBFIRST, two);
  delay(500);
  shiftOut(data, clock, LSBFIRST, three);
  delay(500);
  shiftOut(data, clock, LSBFIRST, four);
  delay(500);
  shiftOut(data, clock, LSBFIRST, five);
  delay(500);
  shiftOut(data, clock, LSBFIRST, six);
  delay(500);
  shiftOut(data, clock, LSBFIRST, seven);
  delay(500);

}

Here is my setup:

Q0   is  A

Q1   is  B

Q2   is  C

Q3   is  D

Q4   is  E

Q5   is  F

Q6   is  G

DS is my data so its connected to pin 12 on Arduino

ST_CP is my clock( latch ) hav that to pin 8 on Arduino

MR  is master reclear and have that to power, try ground and did nothing

SH_CP and OE not connected

 

I'm using this site

http://www.arduino.cc/en/Tutorial/ShiftOut

this is where the code from

http://www.instructables.com/id/The-74HC164-Shift-Register-and-your-Arduino/

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Thanks everyone for their help.  I was stupid and forgot that I needed the latchpin connected to the Arduino I had the clock to it instead.  I just made it turn off before I shiftout and turn it on after and it works perfect.  I had try the arduino tutorial in the past and never could get it to work so I gave up on it so I'm happy it works now.  I did hook everything up as stated in the arduino site and then use the code from instructables with a little modification and it works. So thanks again everyone for knocking a little sense in me lol.

 

Now I can code my LED cube :D

I think we deserve a video now! 8-)

congrats.

Will post the LED cube up once I get a few patterns done, no problem there rik.   :D

A quick look at the datasheet shows that /OE needs to be tied LOW to enable the latch outputs.  /MR needs to be tied HIGH otherwise nothing will happen as the chip is permanently reset.

Your clock from the arduino should be to SHcp, not STcp.

You also need an arduino output connected to STcp and this should normally be LOW.

I know nothing of arduino coding, but if the line "shiftOut(data, clock, LSBFIRST, zero);" pulses the clock (SHcp) 8 times (once for each data bit) then that will load up the storage register correctly. (Just to clarify - sequence should be . . . 1st data bit on Ds, HIGH SHcp, LOW SHcp, 2nd data bit on Ds, HIGH SHcp, LOW SHcp . . .   until 8 bits clocked in.)

All you need then is to set STcp HIGH and then LOW and the storage register contents will be latched through to the outputs and the segments will light.

You could use another arduino output to clear the display (LOW /MR, HIGH /MR) or clock through "00000000" and latch it.  Alternatively, use an arduino output to /OE - A LOW shows the display, a HIGH blanks it.

Andy.

(You have connected the common of the display to 0V, haven't you.)

"MR  is master reclear and have that to power, try ground and did nothing"

This is where you refer to the datasheet for info like this....

sh_cp and OE are not tied to anything, not even ground? If this is the case you could be asking for trouble. Never leave pins floating...otherwise you could get mixed results......based on the DS, I would tie OE to ground SH_CP as well. 

if you say you have this

"SH_CP and OE not connected"

then you are not following the tutorial you just posted

and you should also consider readding the datasheet

there are example codes around the webs, google some, and try them, if they work, then it's something wrong with your code, if not, it's you wiring.

Without more inf, nobody can answer your questions. Heck, you don't even ask any!

Which display are you using? How did your wire it up? Are you following some instruction? Link? What specifically do you need to know? Is there something working right? Make sure to mention that too!

Thanks for the extra info.

Why did you not connect SH_CP? Your tutorial says otherwise. Even I say otherwise. But I never used this chip. So listen to the tutorial. You are mixing hardware and software from two different sources. Keep with the Arduino tutorial. It looks solid. The intructable example uses a different chip. That's why the code won't work.

The same is true for /OE. You kept it "floating". That way the chip does not know what you want from it. Tie it to ground. Just like the tutorial did.

You still did not tell us about the LED display. They are not all the same.

Not really understanding what your saying.  I'm still trying to figure out how this works.  The above code works by turning them on one by one but when I have the byte set to numbers it mess up.  What exactly do I need to do with my code.  Thanks man