I have recently bought some 74HC595N (datasheet) shift registers to play with using my Raspberry Pi. The Raspberry Pi has a general purpose clock that I think I should be able to make use of, however I am unsure how this would work.

Should I have to programaticaly tell the data pin to go high, then tell the clock pin to go high, then pull the clock pin low again just to shift a 1 into the register?

I have written some code that uses the standard GPIO pins to send the data pin either high or low and then pulse the clock to shift the bit into the shift register, which seems to be working (although it is acting a little strange sometimes which is why I'm asking if I have the right idea about using the clock?)

I feel that I've worded the question rather poorly, but I cant think how else to explain my issue. If you have any questions I'll do my best to answer them.

EDIT: I'm wondering now if it could be acting up because of my voltage levels. The data sheet says that if you are powering the chip using 4.5v the minimum HIGH voltage is 3.15v. I'm using 5v to power it (not listed on the datasheet). It also says that if you're powering it with 6v the minimum HIGH voltave is 4.2v, so maybe I'm just not hitting the voltage threshold occasionally? I'm still interested in how to use the clock correctly though.


1 Answer 1


Your idea about programmatically setting the clock and data pins is correct. This technique is often called 'bit-banging'. To find out what goes wrong you should post your code.

The 5V / 3.3V issue could very well be your problem. Try to power the HC595's from 3.3V to see how that affects the problem.

The chip in the RaPi has some dedicated hardware that can be used to interface to SPI peripheral like the HC595. But unless you need to shift data out at the maximum speed the use of such a peripheral is not worth the trouble: bit-banging is much easier.

PS you talk about the clock and data pins, are you aware that there is a second clock (hold clock) that you must pulse once per transferred byte, and that there are a few other pins (reset, enable) that must also be kept at the appropriate level?

  • \$\begingroup\$ Thanks for your answer. If I power the chip from the 3.3v supply, I presume I can still use the 3.3v as a HIGH for my data input as it doesn't specify a max voltage? Also, if I can use any GPIO pin as the clock, why is there a general purpose clock? Thanks again :) \$\endgroup\$
    – OdinX
    Commented Sep 1, 2013 at 15:52
  • \$\begingroup\$ Or switch to 74HCT instead (which has a VIH of 2.4V minimum, within 3.3V CMOS specs; just don't try to connect an output back into the RPi though). \$\endgroup\$ Commented Sep 1, 2013 at 16:12
  • \$\begingroup\$ @Chief17: I don't understand the first question in your remark. The chip sure does specify a max input voltage: Vcc. \$\endgroup\$ Commented Sep 1, 2013 at 16:42
  • \$\begingroup\$ I meant a max voltage for signalling HIGH, but I gave it a go and it works perfectly now. In answer to your last paragraph, yes I am aware and have it all hooked up and working :) Thanks for your help \$\endgroup\$
    – OdinX
    Commented Sep 1, 2013 at 19:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.