Hc595 7 Segment

Hello!

I've bought an hc595 shift register and 4 common anode 7-segment leds.
Now I need any code/ a libarie to control the leds.

Thank you

Lfg2000

Search the Playground to start, there are LED libraries there.

Also, you should be more clear how you plan to multiplex these.
1 segment at a time? You can get by with Arduino driving the anodes, and shift register sinking the cathodes. Need 1 current limit resistor per anode.

1 digit at a time? You will need 4 PNP transistors, 4 base current limit resistors, and 7/8 cathode current limit resistors.
Little more hardware, but the multiplexing will be faster & brighter.

Also notice that although the max sink/source current per pin is 30mA, the max total sink/source current of 74hc595 is only 70mA. If you multiplex one digit (7 or 8 segments) at time and use 220R resistor as in the Arduino shifout tutorial, you may exceed the max current rating. Use big enough cathode resistors so that the total current stays below 70mA when all segments are illuminated. The exact resistor value depends on the forward voltage of the leds, which is typically about 2V with red leds. 330R is probably on the safe side. Or if you want brighter display and drive the leds at higher currents, you can use ULN2003 transistor array between 74hc595 and the cathodes. You still need to pick cathode resistors so that the current stays below the max current/segment (typically about 20mA).

Hello!

My Plan is that I build a electronic calculator.I'll will use a keyboard and 5 buttons. So i need a function/library that writes a 4-Digit Number.

You can open a new tab in the IDE and name it sevenseg.h, then go back to the first tab, include the code

#include"sevenseg.h"

this is a sample program of printing values on a seven segment display.

#include"sevenseg.h"
int val=0;
void setup(){
  sevensegpins(13, 12, 11, 10, 9, 8, 7);
  common_cathode(true);
}
void loop(){
  val=(analogRead(0));
  val=map(val, 0, 1023, 0, 9);
  sevenseg(val);
}

Or you can use this
http://playground.arduino.cc/Code/SevenSegment

Good morning from Europe!

The library is very good. Has anyone example code about a circuit with 4 shift registers?

Thank you for your Help

Lfg-2000

The answer depends on how you wire them up.

I need help to bulid a 4 Digit cascade.

Thank you

Lfg-2000