shift registers aren't working on teensy

Status
Not open for further replies.
Hello,
I have another problem with my teensy but this time it's related to shift registers. I am trying to do a small keyboard piano that has keys made of metal, and when you touch a key it makes a sound. That is the end goal, and it will be polyphonic. Right now, I am testing out shift registers so that I could use them to control many inputs, but my tests don't work. I have two 74hc595 in series and this is the code that I have uploaded to the teensy:

Code:
//Pin connected to ST_CP of 74HC595
int latchPin = 8;
//Pin connected to SH_CP of 74HC595
int clockPin = 12;
////Pin connected to DS of 74HC595
int dataPin = 11;



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 (int numberToDisplay = 0; 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);
    // pause before next value:
    delay(500);
  }
}
I believe that this code is supposed to count the LEDs in binary every half seccond, but it actually does nothing on the shift registers... I have enclosed some images of my setup, the LEDs just stay the same. By the way, I'm using 3.3v for the teensy and 5v for the shift registers/LEDs, and I have a biderectional logic level converter for the teensy to comunicate with the shift registers. The reason I dont use the same voltage everywhere is that I have some BC548B transistors that I plan on using for the key sensors, and I believe they only work on 5v. If you have an alternative transistor that works on 3.3v, please let me know.
 

Attachments

  • 20171226_123243.jpg
    20171226_123243.jpg
    153.7 KB · Views: 99
Try slowing Teensy to only 24 MHz, just in case the problem is the circuits can't handle the speed of the signals. Usually shift register chips are ok, but bidirectional logic level shifters sometimes have speed issues.
 
you were right, I plugged the shift register inputs directly to the teensy's outputs and the LEDs started to count in binary :), since 3.3v is an acceptable logic level for a 5v device...

but now i need to connect one 5v input into the teensy... Do you have any suggestions? It would make my life a lot easier if i just had an equivalent transistor that is bc548b but in 3.3v version... I'd like to make the same kind of circuit in this video but with transistors instead of push buttons:
https://www.youtube.com/watch?v=nXl4fb_LbcI&t=661s
 
Status
Not open for further replies.
Back
Top