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

Thread: shift registers aren't working on teensy

  1. #1
    Junior Member
    Join Date
    Dec 2017

    shift registers aren't working on teensy

    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:

    //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:
    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.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	20171226_123243.jpg 
Views:	16 
Size:	153.7 KB 
ID:	12393  

  2. #2
    Senior Member manitou's Avatar
    Join Date
    Jan 2013
    I can't quite see the shift-register orientation, and whether OE is pulled to GND. maybe start with one shift register and everything at 3v3.

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    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.

  4. #4
    Junior Member
    Join Date
    Dec 2017
    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:

Posting Permissions

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