Ceramic capacitors and the 74HC595 shift register

Hi,
I am making a pedometer with an Arduino micro and am using a shift register to drive a 4 digit 7 segment display which displays the number of steps. Just wondering if I need a ceramic capacitor on the clock pin of the shift register to protect it.
Thanks in advance

Adding a capacitor to the clock pin will most likely prevent your circuit from working.

1 Like

Connect the capacitors between Vcc and GND.

Have you thought about clocking a decade counter chip instead of a shift register? The decoding from BCD to 7-seg display would be easier, I think.

A MAX7219 using SPI might be the best option for a 7 segment display.

image

image

image

1 Like

Thanks everyone for your help. It is very much appreciated.

Hi @LarryD , thanks for the detailed information. Is there a variant of the Max7219 that has only 4 digits on the display as that is the only size that will fit in my enclosure?
Thanks

The MAX7219 can be used with 4 seven segment digits.

image

1 Like

Hi LarryD, thanks for that information. I've had a look online and when I search for the Max 7219 I only get results for boards with an integrated 8 digit display. I would be grateful if you could post me a link of a site I could purchase a Max 7219 from.
Thanks

image



1 Like

Hi Larry@D,
thanks very much for all of your help. It 's very much appreciated.

Remember the 7219 drives a common cathode seven segment display.

Here is a sketch to get you started with the MAX7219:

/*
   SPI_Max7221/7219
*/

#include <SPI.h>

const int slaveSelect    = 10; //pin used to enable the active slave

const int numberOfDigits = 4;  // change to match the number of digits wired up
const int maxCount       = 9999;

int count;

//**********************************************************************
void setup()
{
  SPI.begin();   // initialize SPI

  pinMode(slaveSelect, OUTPUT);
  digitalWrite(slaveSelect, LOW);      //select slave

  //prepare the 7221/7219 to display 7-segment data - see data sheet
  sendCommand(15, 0);                  //Display test off
  sendCommand(12, 1);                  //normal mode (default is shutdown mode);
  sendCommand(11, numberOfDigits - 1); //7221 digit scan limit command, 0 relative
  sendCommand(10, 8);                  //set medium intensity (range is 0-15)
  sendCommand(9, 255);                 //decode command, use standard 7-segment digits

  digitalWrite(slaveSelect, HIGH);     //deselect slave

  //displayNumber(count);

} //END of setup()

//**********************************************************************
void loop()
{
  count = count + 1;

  if (count > maxCount)
  {
    count = 0;
  }

  //send the current count to the MAX7219
  displayNumber(count);

  delay(100);

} //END of loop()

//**********************************************************************
//function to display up to four digits on a 7-segment display
void displayNumber( int number)
{
  //sending all the digits to the display
  for (int i = 0; i < numberOfDigits; i++)
  {
    //get the value of the rightmost decade
    byte character = number % 10;

    //sendCommand(reg,data)
    sendCommand(numberOfDigits - i, character);

    //next digit
    number = number / 10;
  }

} //END of  displayNumber()

//**********************************************************************
void sendCommand( int reg, int data)
{
  digitalWrite(slaveSelect, LOW); //chip select is active low

  //2 byte data transfer to the 7221/7219
  SPI.transfer(reg);
  SPI.transfer(data);

  digitalWrite(slaveSelect, HIGH); //release chip, signal end transfer

} //END of sendCommand()



1 Like

Hi @LarryD,
thanks so much for the info and the sketch.

I’m driving 8 x 8x8 matrices with mkr zero and I found that SPI very temperamental not to mention that default SPI.begin() just breaks it, only beginTransaction with SPISetting works, and even that gets wierd trying to run all 8 in cascade. ShiftOut on the other hand is as solid as a rock.

Yes, but that is somewhat misleading to say.

It drives common anode displays perfectly well. :face_with_raised_eyebrow:

This is a misunderstanding resulting from a particularly stupid blunder in the Arduino tutorials.

I use 8 and 4 digit all the time with SPI, I’ve never experienced that problem.

Yes CA can be used but with software contortion :upside_down_face:

Not familiar with mkr zero, what voltage is the controller ?

If 3v, I believe there is a special 3v version of the 7219.

3.3v, I have no idea what version of controller, it is under the led matrix which is not removable. the seller indicated it needs 5v and it seems ok