Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: LED Ring with 595 shift register - pinout/bit order?

  1. #1
    Junior Member
    Join Date
    Aug 2017
    Posts
    13

    LED Ring with 595 shift register - pinout/bit order?

    I am trying to control a LED Ring (consisting of single LEDs ) through a 595 shift register (it will be 15 LEDs through 2 registers but for my testing setup, I am just using 8 LEDs and a single 595).
    Everything works fine when testing, however one thing has me very confused. I triple checked the wiring but it seems to either send the bits in a wrong order or my pinout is different. What happens in the following testcode is that the LED connected to output H/7 (0-indexed) on pin 7 displays the LSB.
    output A/0 puts out the 2nd LSB
    .....
    output G/6 puts out the MSB

    Code:
    //Pin connected to ST_CP of 74HC595
    int latchPin = 7;
    //Pin connected to SH_CP of 74HC595
    int clockPin = 8;
    ////Pin connected to DS of 74HC595
    int dataPin = 9;
    
    void setup() {
      //set pins to output so you can control the shift register
      pinMode(latchPin, OUTPUT);
      pinMode(clockPin, OUTPUT);
      pinMode(dataPin, OUTPUT);
    }
    
    void loop() {
      // count from 0 to 255 and display the number 
      // on the LEDs
      for (byte numberToDisplay = 1; numberToDisplay < 256 ; numberToDisplay++ ) {
        // take the latchPin low so 
        // the LEDs don't change while you're sending in bits:
        digitalWrite(latchPin, LOW);
        // shift out the bits:
        shiftOut(dataPin, clockPin, MSBFIRST, numberToDisplay);  
    
        //take the latch pin high so the LEDs will light up:
        digitalWrite(latchPin, HIGH);
       
    
    char debugmsg[16];
    sprintf(debugmsg,"Writing %d\t",numberToDisplay);
     
       Serial.print(debugmsg);
    
        delay(20);
       
      }
    }

    I can't seem to find any fault in the code itself (tried changing int to byte, MSBFIRST to LSBFIRST to no avail) and I did triple check my wiring. Being new to the physical side of it (working with chips etc) , I wonder if there's any chance that my 595 has an unusual/weird pinout (although that doesn't seem too likely)? Or did I misunderstand in what order the bits are written / the routing or whatever?

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,085
    Normally the latch pin is pulsed after you complete the shift. So do both digitalWrite after shifting.

    But my guess is you hardware may be wired incorrectly. If you want good help, you really need to post photos showing the wiring.

  3. #3
    Junior Member
    Join Date
    Aug 2017
    Posts
    13
    Ok, it might look a bit messy but i scraped the edges and tested for shorts.
    In the overview, the 5 cables (3 yellow, 1 red, 1 black) in the top left go to the teensy (yellow) / power rail. The 2 closeup pictures of the LED wires / the IC show the problem child connected . This is L7 marked in blue on the marked back of the circuit


    http://imgur.com/a/GQK8D


    https://youtu.be/HATv94Q4C6g

    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •