Pages: [1]   Go Down
Author Topic: Hc595 7 Segment  (Read 814 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 437
Posts: 23662
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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.

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 437
Posts: 23662
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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.

Finland
Offline Offline
Sr. Member
****
Karma: 0
Posts: 270
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Beijing
Offline Offline
Full Member
***
Karma: 3
Posts: 193
Skype name habib.derbyshire
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#include"sevenseg.h"
this is a sample program of printing values on a seven segment display.
Code:
#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);
}
Logged

What is man's best friend? The breadboard!

Beijing
Offline Offline
Full Member
***
Karma: 3
Posts: 193
Skype name habib.derbyshire
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

What is man's best friend? The breadboard!

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The answer depends on how you wire them up.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I need help to bulid a 4 Digit cascade.

Thank you

Lfg-2000
Logged

Pages: [1]   Go Up
Jump to: