74HC595 & 7 Segment LED Hook Up

Hi All,

I Have tried searching for the correct way to hook up a 7 Segment Common anode LED to a 74HC595.

I made the Modular Plug using Fritzing: http://fritzing.org/projects/shiftregister-modular/ and have tested it with LEDS.

All works OK!!

Any suggestions on how to hook them up?

Thanks In advance

Common anode is common posotive. Connect the common positive to +5V. Then get the proper resistors for each segment. Connect the cathode of each segment to a resistor. You will also need a ULN2803A because the 74HC595 can only supply posotive voltage. Conenct the Q0-7 of the shift register to the bases of the transistors (Pins 1-8 on the ULN2803A.). Then connect 0V to pin 9, and +5V to pin 10. Pins 18-11 go to the other side of the resistors on the display.

Then you turn a pin high on the 74HC595, and the according segment turns on. :)

-Jeremy

Thanks for the reply,

What I was actually looking for was Segment Pin to Q (595) pin.

Searching seems to bring up loads of codes but never see anyone describe what pin is connected to what?

I don't have an ULN2803A, Can it work without one? or can I use individual NPN's

Thanks again!!

Me and richard are basically saying the same thing... the only thing is that the ULN2803A is basically 8 NPN transistors in one package...

My only other idea would be to hook the cathodes directly to Q0-7, and then turning the pin high means it's off and turning it low tuens the segment on...? It's worth a try... If not, use my above idea.

Oh so if I use a common cathode one?

Yes, this is for common cathode (common negative).

Well that makes sense,

Im going to head to my local electronics store and get one (common cathode) in the morning.

If i connect it up:

Q0 - A Q1 - B Q2 - C Q3 - D Q4 - E Q5 - F Q6 - G Q7 - H

How can i address the pins to create digits?

are there any libraries so i can use int values?

OK,

So what is the correct set-up?

I always see the 595 IC as the driver! even in the Arduino Playground gives an example of the 595 lighting led.

Im a bit confused!

I am so lost in this… Here’s my take at things:

You hook each segment to a resistor. You hook the anode to +5V. The other side of each resistor goes to
A. Directly to the Q0-7 of the 74HC595 chip.
B. To the collectors on a ULN2803A, and the bases of that same chip go to the Q0-7 on the 74HC595

For A: To light up a segment on the display, you turn the corresponding Q pin LOW.
For B: To light up a segment on the display, you turn the corresponding Q pin HIGH.

-Jeremy :-?

For A: To light up a segment on the display, you turn the corresponding Q pin LOW. For B: To light up a segment on the display, you turn the corresponding Q pin HIGH.

Yep.

How can i address the pins to create digits? are there any libraries so i can use int values?

Here's an example of a lookup table for getting the segment values (not written for Arduino but should work the same).

uint_8 LED_data [] = {                // abcdefg.
            0xfc,      //       0       %11111100
            0x60,      //       1      %01100000
            0xda,      //       2      %11011010
            0xf2,      //      3      %11110010
            0x66,      //      4      %01100110
            0xb6,      //      5      %10110110
            0xbe,      //      6      %10111110
            0xe0,      //      7      %11100000
            0xfe,      //      8      %11111110
            0xf6,      //      9      %11110110
            0xee,      //      A      %11101110
            0x3e,      //      b      %00111110
            0x9c,      //      C      %10011100
            0x7a,      //      d      %01111010
            0x9e,      //      E      %10011110
            0x8e      //      F      %10001110      
      };

Abviously the actual values may be different for your application.

Then grab the values using something like this.

void mainLEDout (uint_16 val) {
       uint_16 tx_word;

      // get lower nibble bit pattern from table
      tx_word = (LED_data[(val & 0x00f0)>>4]) ;

       // get upper nibble bit pattern from table then OR into upper byte
       tx_word |= LED_data[val & 0x000f] << 8;

      your_output_value_function (tx_word);
}

hey guys. i just ordered a bunch of 595's and a common anode display. im a total neewbie to electronics but could i use a hex inverter like the 4069(or a NOT gate) to change the polarity of the 595's output. thanks in advanced

You could but it's much easier to just invert the data you send to the 595, bit low = led on, bit high = led off.

As mentioned above the 595 is not really a LED driver but for playing around it should work. One of the high-current equivelants like a TPIC6B595 would be better.

Why not just have a method that when passed a uint_8 returns a byte to be shifted out using a switch statement? It is how I have done it before now...

You're right, that's the neat way to do it. I posted something similar in post #14, it takes a uint_16 and turns it into two 8-bit patterns suitable for shifting out.

As it can only print up to FF it didn't need a uint_16, I think I was allowing for shifting 3-4 bytes in future.

The inversion/non inversion can be handled statically by having the correct values in the LED_data array, or dynamically buy XORing the data before transmitting.

ya that would be easier to just have high=led of and vice versa. although remember im a really total neewbie to arduino and electronics so doing the whole 16 bit ->2 8-bit thing sounds really confusing. thanks for the replies