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

Thread: Teensy LC 74HC595 problems

  1. #1
    Junior Member
    Join Date
    Dec 2018
    Posts
    7

    Teensy LC 74HC595 problems

    Hi

    I've been trying to use the 74HC595 with the Teensy LC, but I'm not having much luck.

    Although the end intent is to make a button matrix, I've been trying to test it using LEDs, but they do not light up at all.

    My Circuit:
    Click image for larger version. 

Name:	circuit.png 
Views:	15 
Size:	35.5 KB 
ID:	17805
    My Breadboard:
    Click image for larger version. 

Name:	breadboard.jpg 
Views:	15 
Size:	93.8 KB 
ID:	17806
    My Code (no error messages):
    Code:
    // teensy tto 74hc595 - column light up
    
    //connections to 74hc595
    int latchPin = 8;
    int clockPin = 13;
    int dataPin = 11;
    
    // shifting values
    byte patterns[8]={
      B00000001,
      B00000010,
      B00000100,
      B00001000,
      B00010000,
      B00100000,
      B01000000,
      B10000000
    };
    
    int current = 0;
    int count = sizeof(patterns);
    
    void setup() {
    
      // set serial pins to output
      pinMode(latchPin, OUTPUT);
      pinMode(dataPin, OUTPUT);  
      pinMode(clockPin, OUTPUT);
    }
    
    void loop() {
    
      //write to shift registor
        digitalWrite(latchPin,LOW);
        shiftOut(dataPin, clockPin, MSBFIRST, patterns[current]);
        digitalWrite(latchPin, HIGH);
    
        delay(500);
    
      //increase current
        current++;
      //reset current
      if(current >= 8){
        current = 0;
      }
    }
    Additional testing:
    • Tested each wire and LEDs
    • Rechecked all LEDs are the right way round
    • Teensy LC onboard LED (pin 13) flashes - so it is working


    Software: Arduino 1.8.8 and Teensyduino
    Hardware: Teensy LC and 74HC595 (Texas Instruments SN74HC595N)
    Additional Libraries: None


    I'm not sure what I'm doing wrong and would be grateful for any help

    Thank you

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,681
    I don't see the GND wire from the LEDs back to the 74HC595 chip.

  3. #3
    Junior Member
    Join Date
    Dec 2018
    Posts
    7
    Before taking the photo I removed each jumper wire to continuity test just in case - I forgot the GND wire when reassembling.

    I've now reattached the GND from the LEDs to the the 74HC595 chip, but the result is the same - no lights

    EDIT:
    Plugged in the teensy again to test and check if any wires were loose, and this time we have one LED light up. Unfortunately the LEDs are meant to cycle though which one of them is lit.
    I'm not sure where to go from here - I don't now if it is circuit problems or code.

    Second Edit:
    Unplugged and fiddled about with the wires to make sure they are all fully in. Powered up the teensy and the LED light sequence now fully works.

    I might have to get some new jumper wires and breadboards to remove the inconsistency.
    Last edited by Redgeneral; 10-05-2019 at 09:09 PM. Reason: New development

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,681
    Oh, defective breadboard wires are the worst!

  5. #5
    Junior Member
    Join Date
    Dec 2018
    Posts
    7
    New breadboards and wires arrived today, so I rebuilt the circuit and it worked first time.

    I've now increased it to 3 x 74hc595 chips for 24 columns, displaying 1 led at a time. My updated code:
    Code:
    // -----------------------------
    // teensy 24 led columns - 
    // cycles through to light up
    // one LED at time
    // -----------------------------
    
    // connections to 74hc595
      int latchPin = 8;
      int clockPin = 13;
      int dataPin = 11;
    
    // count
      int count = 1;
      int countTotal = 24;
    
    // shifting values
      byte patterns[8]={
        B00000001,
        B00000010,
        B00000100,
        B00001000,
        B00010000,
        B00100000,
        B01000000,
        B10000000
      };
    
    // temp values
      byte tempA = B00000000;
      byte tempB = B00000000;
      byte tempC = B00000000;
    
    void setup() {
      // put your setup code here, to run once:
    
      // set serial pins to output
        pinMode(latchPin, OUTPUT);
        pinMode(dataPin, OUTPUT);  
        pinMode(clockPin, OUTPUT);
    
    }
    
    void loop() {
      // put your main code here, to run repeatedly:
    
      //update and reset
        if (count<9){
          tempA = patterns[count-1];
        }else{ 
          tempA= B00000000;
        }
        
        if (count<17 && count>8){
          tempB = patterns[count-8-1];
        }else{ 
          tempB= B00000000;
        }
        
        if (count>16){
          tempC = patterns[count-16-1];
        }else{ 
          tempC= B00000000;
        }
    
    
      //write to shift registor
        digitalWrite(latchPin,LOW);
        shiftOut(dataPin, clockPin, MSBFIRST, tempC); //3of3
        shiftOut(dataPin, clockPin, MSBFIRST, tempB); //2of3
        shiftOut(dataPin, clockPin, MSBFIRST, tempA); //1of3
        digitalWrite(latchPin, HIGH);
    
      //wait
        delay(500);
    
      //loop variable
        count++;
        if (count>24){
            count=1;
        }
    }
    Now that I have the shift output code working, I can now get underway with my project design. The LEDs are going to be replaced with rows of switches to create a 24x10 button matrix.

Posting Permissions

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