• I've been trying to light a few LEDs using the above shift register without success. I'm having to translate from Arduino guides to Espruino/Puck.js, so undoubtedly I've got something wrong.

    I've tried using SPI1.setup() as well as let s = new SPI(); s.setup();, but neither work.

    The options I'm passing to setup are:

      let options = {
        sck: PINS.CLOCK,
        // miso: PINS.LATCH,
        mosi: PINS.DATA,
        order: 'lsb',
        mode: 0,

    And I've tried using s.write([0, 1, 0, 0, 0, 0, 0, 0], PINS.LATCH) as well as manually setting the latch low/high around the write.

    Wiring is as follows (the comment is the pin number on the shift register itself):

    const PINS = {
      DATA: D28, // 14
      LATCH: D29, // 12
      CLOCK: D30, // 11

    And finally, I've supplied power and ground where required (I think!), at pin 1 for ground, and pins 10 (SRCLR) and 16 (VCC) are high.

    Absolutely any help at all will be massively appreciated. Thanks!

  • You might consider posting your entire program. But I'm thinking, s.write sends characters, not bits. Is that your intent? You might be shifting a lot of binary zeros before the transfer to the output.

  • Oh! Well, that's interesting.

    I've switched to using SPI1.write(0b01000000, PINS.LATCH) and that almost works perfectly, except when I turn two adjacent LEDs on, one of them is extremely dim. I suspect that's just bad wiring or low battery, since if I turn them on individually, they work fine.

    I can't believe it was such a simple mess up on my part. Thanks!

  • And now it's not working at all again, and I've no idea why! 😭

    Edit: I think that failure was a dry joint or bad wire. Ugh!

  • Glad I could help. I have a few decades of experience in discrete logic. When I saw 74HC... I was intrigued. Sounds like you are a lot closer to your goal. Good luck!!

  • when I turn two adjacent LEDs on, one of them is extremely dim

    You might share your circuit schematic. How are your LEDs biased?

  • I don't know what 'bias' means in this context.

    I'm a developer, so confident of my code, but an electronics noob. Pretty sure it's working sensibly now, but either my breadboard has a bad connection with a wire, or I've soldered a wire badly. I wouldn't know how to share a schematic either, other than to take a picture of what I've got!

    Thanks for your help though. 👍🏼

  • Are you powering the shift register and LEDs from the watch battery? Sounds possible if two LEDs on are dim?

    It might be that your battery is running down! 74 series logic probably won't work that well at lower voltages.

    While the watch battery is generally enough for Puck.js, as soon as you start powering external things (or executing code really frequently) you can run it down in no time at all!

    To get around it, you should be able to power your shift register and LEDs from an external source of power, and connect only ground, data, latch and clock - so leaving Puck.js working off its own battery (so you don't have to worry about keeping the voltage it is powered from within range).

  • I've got a 3.3v power supply unit which I was using, but later also tried it just off the battery.

    I've no idea what was causing the dimness – that's since gone away. Bad wiring or dodgy configuration is entirely likely!

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Attempting (and failing) to use a 74HC595 Shift Register

Posted by Avatar for Drarok @Drarok