Hello!
I'm experimenting with a double digit seven segment display, and I was outraged by the amount of cables and resistor need to write a number!
I thought something better can be made… and so I end up in gather information on shift register.
I find many examples suggesting some sort of 74HCXXX cmos… but I'm confused by all the different 74HC chips available.
The simple answer is no.
Not every 74HCXXX chip is the same.
However, all different brands of 1 model (74HC595, to take a well known one) should be the same.
You can do it with one chip, one resistor, and a bit of wiring.
The MAX7219 will drive up to 8 x 7-segment displays (plus the decimal point) with only a single resistor to set the current. You communicate via SPI so you only need 3 wires between the chip and your Arduino, plus +5V and Gnd.
Sketch:
#include <SPI.h>
const byte SS = 10; // omit this line for Arduino 1.0 onwards
const byte MAX7219_REG_NOOP = 0x0;
// codes 1 to 8 are digit positions 1 to 8
const byte MAX7219_REG_DECODEMODE = 0x9;
const byte MAX7219_REG_INTENSITY = 0xA;
const byte MAX7219_REG_SCANLIMIT = 0xB;
const byte MAX7219_REG_SHUTDOWN = 0xC;
const byte MAX7219_REG_DISPLAYTEST = 0xF;
void sendByte (const byte reg, const byte data)
{
digitalWrite (SS, LOW);
SPI.transfer (reg);
SPI.transfer (data);
digitalWrite (SS, HIGH);
} // end of sendByte
void setup ()
{
SPI.begin ();
sendByte (MAX7219_REG_SCANLIMIT, 3); // show 4 digits
sendByte (MAX7219_REG_DECODEMODE, 0xFF); // use digits (not bit patterns)
sendByte (MAX7219_REG_DISPLAYTEST, 0); // no display test
sendByte (MAX7219_REG_INTENSITY, 7); // character intensity: range: 0 to 15
sendByte (MAX7219_REG_SHUTDOWN, 1); // not in shutdown mode (ie. start it up)
} // end of setup
void number (int num)
{
char buf [5];
sprintf (buf, "%4i", min (max (num, 0), 9999));
// send all 4 digits
for (byte digit = 0; digit < 4; digit++)
{
byte c = buf [digit];
if (c == ' ' )
c = 0xF; // code for a blank
else
c -= '0';
sendByte (digit + 1, c);
}
} // end of number
unsigned int i;
void loop ()
{
i++;
number (i);
delay (100);
} // end of loop
Like : 74HC00, 74HC04, 74HC74, 74HC595 <-- not the same. Different numbers.
To use one... It depend on the chip.
any one will be good to control a 2 digit seven segment display (CA)
The chip to display a ca, I did use a 74LS47 ( a BCD to seven segments display ). You may find a 74HC47 version. You still need limiting resistors ( 330 ohms to 470 ohms ) at each segments. I use a resistor network ( 330 ohms or 470 ohms ) chip in my project ( all resistors separated inside ) And to turn a digit on, you use a PNP transistor with a base resistor ( 1 k to 4.7 K ) and need a LOW signal to turn the transistor ON.
The 74HC595 or MAX7219 use a serial to parallel to show the display.
But it is still depend what you are planning to do, avaibility of the chip and price of the chip will determine the parts of your project.
Is what I'm looking for? (a shift register equivalent to the 74HC595?)
The 4021 is a parallel-in/serial-out shift register. It's useful for extending the number of switch inputs to an Arduino but not for extending the number of outputs.
The 4015 (Dual 4-Stage Static Shift Register) is a parallel-out shift register (closer to what you want). It has two 4-bit stages which can be chained together to make one 8-bit shift register.
Or are you in the UK? Well they have a Digi-key too, it seems. Looks like a minimum order of 50 Pounds for free delivery, I don't know how much for delivery otherwise. Looks like they are 42p there.