Teensy LC 74HC595 problems

Status
Not open for further replies.
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:
circuit.png
My Breadboard:
breadboard.jpg
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
 
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:
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.
 
Status
Not open for further replies.
Back
Top