Go Down

Topic: 595 Shift register problems. (Read 993 times) previous topic - next topic


Sep 10, 2012, 05:10 am Last Edit: Sep 10, 2012, 06:58 am by Riley-NZL Reason: 1
I bought two 74HC595 shift registers with plans of using them to power 4x7 segment displays, and am working through this tutorial to learn how to use them: http://arduino.cc/en/Tutorial/ShiftOut

I am fairly certain everything is wired up ok, loaded the first program but all it does it just light the first LED continually, where from the discription it should cycle through the numbers 0-255 in binary using the 8 LED's.

All the tutorial I can find use common cathode 4x7 segment displays, however the ones I bought are common anode, does anyone now of a tutorial for powering a common anode 4x7 segment display using 595 shift registers?


An attempt at photographing the setup:


Do you have the 1uF cap on the ST_CP pins? Take that off.
Put a 0.1uF cap from Vcc on the 595s to nearest Gnd.

"common annode 4x7 segment displays, however the ones I bought are common anode,"
Well, I am pretty sure 1 extra n in anode won't make much difference.

The shiftout uses common cathode.
If you  have common anode, then you need drive the cathodes low to turn the segments on.

So instead of 1 indicating an On segment here:
Code: [Select]

 //Arduino doesn't seem to have a way to write binary straight into the code
 //so these values are in HEX.  Decimal would have been fine, too.
 dataArrayRED[0] = 0xFF; //11111111
 dataArrayRED[1] = 0xFE; //11111110
 dataArrayRED[2] = 0xFC; //11111100
 dataArrayRED[3] = 0xF8; //11111000
 dataArrayRED[4] = 0xF0; //11110000
 dataArrayRED[5] = 0xE0; //11100000
 dataArrayRED[6] = 0xC0; //11000000
 dataArrayRED[7] = 0x80; //10000000
 dataArrayRED[8] = 0x00; //00000000
 dataArrayRED[9] = 0xE0; //11100000

a 0 will indicate on instead - flip all the bits over.
For example, define a digitArray:
Code: [Select]

digitArray[0] = {B01000000};  //bit 0 = segment A, 1 = B, 2 = C, 3 = D, 4 = E, 5 = F, 6 = G, 7 = decimal point is used
digitArray[1] = {B00000110};
digitArray[2] = {B01011011};
digitArray[3] = {B01001111};
digitArray[4] = {B01100110};
digitArray[5] = {B01101101};
digitArray[6] = {B01111101};
digitArray[7] = {B00000111};
digitArray[8] = {B01111111};
digitArray[9] = {B01110011};

and send the data out via SPI:

digitalWrite (SS, LOW);
SPI.transfer (digitalArray[hi_number_to_send]);
SPI.transfer (digitalArray[lo_number_to_send]);
digitalWrite (SS, HIGH);

hi_number_to_send & lo_number_to_send are values from 0 to 9

SCK is connected to RCK on both chips
SS is connected to SRCK on both chips
MOSI is connected to serial data in on chip 1, Q7/ from chip 1 goes to serial data in on chip 2
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.


Hi, not using a cap at all, I'll give that a try.

And sorry, meant the guides are for common cathode.

Go Up