Go Down

Topic: [Solved] 74HC595 Shift register not working (Read 917 times) previous topic - next topic


Jan 21, 2019, 02:08 pm Last Edit: Jan 22, 2019, 08:20 am by TheTrialBot
Hello, I have been following the tutorial at:

When I paste the code from example 1.2, all the LEDs light up. Then when I type a number in the serial monitor, the first LED comes (from Q0/ Pin 15) on and the LED number I pressed flashes for a brief second. Then if I type another number, the LED number I typed will flash for a second but the first led will stay on.

Also I am a bit confused with the capacitor in the circuit diagram. On the drawing of the Arduino and the breadboard, the capacitor is from pin 12 to ground. But on the circuit diagram, the capacitor is from Vcc to ground. On the circuit diagram is says the capacitor is 10µF but step 2 says that the capacitor should be 0.1"f. Does 0.1"f mean 0.1µf? So which capacitor should I use?

Code of Arduino:
Code: [Select]
  Shift Register Example
 for 74HC595 shift register

 This sketch turns reads serial input and uses it to set the pins
 of a 74HC595 shift register.

 * 74HC595 shift register attached to pins 8, 12, and 11 of the Arduino,
 as detailed below.
 * LEDs attached to each of the outputs of the shift register.

 Created 22 May 2009
 Created 23 Mar 2010
 by Tom Igoe


//Pin connected to latch pin (ST_CP) of 74HC595
const int latchPin = 8;
//Pin connected to clock pin (SH_CP) of 74HC595
const int clockPin = 12;
////Pin connected to Data in (DS) of 74HC595
const int dataPin = 11;

void setup() {
  //set pins to output because they are addressed in the main loop
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT); 
  pinMode(clockPin, OUTPUT);

void loop() {
  if (Serial.available() > 0) {
    // ASCII '0' through '9' characters are
    // represented by the values 48 through 57.
    // so if the user types a number from 0 through 9 in ASCII,
    // you can subtract 48 to get the actual value:
    int bitToSet = Serial.read() - 48;

  // write to the shift register with the correct bit set high:
    registerWrite(bitToSet, HIGH);

// This method sends bits to the shift register:

void registerWrite(int whichPin, int whichState) {
// the bits you want to send
  byte bitsToSend = 0;

  // turn off the output so the pins don't light up
  // while you're shifting bits:
  digitalWrite(latchPin, LOW);

  // turn on the next highest bit in bitsToSend:
  bitWrite(bitsToSend, whichPin, whichState);

  // shift the bits out:
  shiftOut(dataPin, clockPin, MSBFIRST, bitsToSend);

    // turn on the output so the LEDs can light up:
  digitalWrite(latchPin, HIGH);


I've made sure that all the wires are the same as the ones in the tutorial but it still doesn't work. Is it because I don't have a capacitor and if so where do I put it?



According to this:
The capacitor should be between Vcc and ground and the other diagrams in that tutorial are wrong.

There is a new issue for the still-wrong diagrams here:

You're the first to report the "f typo. You are correct that it should be uF. I've put this on my "to-do" list of documentation issues and I'll do what I can to get that fixed. Thanks for reporting it!


Thanks! What value capacitor should I use?


Thanks! What value capacitor should I use?
Either of those values or really anything in that neighborhood will work.  You just need to decouple any AC on the line from the pin.  The exact value isn't terribly important. 
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.


Thanks. That answers my question.

Go Up