Go Down

Topic: Hc595 7 Segment (Read 1 time) previous topic - next topic

lfg2000

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

CrossRoads

Search the Playground to start, there are LED libraries there.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

CrossRoads

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.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

pekkaa

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).

lfg2000

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.

arduinohabib

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

#include"sevenseg.h"

this is a sample program of printing values on a seven segment display.
Code: [Select]

#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);
}
What is man's best friend? The breadboard!

arduinohabib

Or you can use this
http://playground.arduino.cc/Code/SevenSegment
What is man's best friend? The breadboard!

lfg2000

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



dhenry

The answer depends on how you wire them up.

lfg2000

I need help to bulid a 4 Digit cascade.

Thank you

Lfg-2000

Go Up