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

Thread: Keypad Problem with Teensy 4

  1. #1
    Junior Member
    Join Date
    Aug 2020
    Location
    Germany
    Posts
    6

    Keypad Problem with Teensy 4

    Hello everyone,

    Problem :
    I used the same pins no. for the keypad for Teensy 3,2 and 4, when I connect the keypad to Teensy 3,2 it works fine, but when I connect it to Teensy 4 it displays an automatic number that I did not press. I use the same Cable.

    I have checked (R1,R2,R3,R4,C1,C2,C3) the keypad and Teensy 4 with a multimeter and the signal is OK (e.g. when I press 1, R1 and C1 make contact).

    What should I have to check?

    Thank you in advance and I await your reply.

    Regards
    Sandip

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    10,948
    Quote Originally Posted by Sandip View Post
    Hello everyone,

    Problem :
    I used the same pins no. for the keypad for Teensy 3,2 and 4, when I connect the keypad to Teensy 3,2 it works fine, but when I connect it to Teensy 4 it displays an automatic number that I did not press. I use the same Cable.

    I have checked (R1,R2,R3,R4,C1,C2,C3) the keypad and Teensy 4 with a multimeter and the signal is OK (e.g. when I press 1, R1 and C1 make contact).

    What should I have to check?

    Thank you in advance and I await your reply.

    Regards
    Sandip
    Hard to say for sure, without seeing more information, like what code is run, using library? if so which one, and wiring...
    But guessing, that maybe timing issue. Like again don't know what keypad code you are using, but for example if you do a digitalWrite(...) to change rows or columns, maybe add a real small delay before you then read the pins and see if that helps.

  3. #3
    Junior Member
    Join Date
    Aug 2020
    Location
    Germany
    Posts
    6
    Quote Originally Posted by KurtE View Post
    Hard to say for sure, without seeing more information, like what code is run, using library? if so which one, and wiring...
    But guessing, that maybe timing issue. Like again don't know what keypad code you are using, but for example if you do a digitalWrite(...) to change rows or columns, maybe add a real small delay before you then read the pins and see if that helps.

    Hello,

    Below I have posted the code for the keypad.

    Can i add time delay before char customKey = customKeypad.getKey()??


    Code:
    #include <Keypad.h>
    
    const byte ROWS = 4; //four rows
    const byte COLS = 4; //four columns
    //define the cymbols on the buttons of the keypads
    char hexaKeys[ROWS][COLS] = {
      {'1','2','3'},
      {'4','5','6'},
      {'7','8','9'},
      {'*','0','#'}
    };
    byte rowPins[ROWS] = {23, 22, 21, 20};
    byte colPins[COLS] = {12, 11, 9};
    
    Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); 
    
    void setup(){
      Serial.begin(9600);
    }
      
    void loop(){
      char customKey = customKeypad.getKey();
      
      if (customKey){
        Serial.println(customKey);
      }
    }
    Last edited by KurtE; 07-28-2022 at 06:45 PM.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,787
    As a first very simple test to check if slower speed helps, try setting Tools > CPU Speed to only 24 MHz and upload again.

  5. #5
    Junior Member
    Join Date
    Aug 2020
    Location
    Germany
    Posts
    6
    Hello Paul,

    Thank you very much for your answer. I changed my CPU speed to 150 MHz (Tools->CPU Speed) and now it works fine. Thank you again.

    Have a nice day.

    Regards
    Sandip

Posting Permissions

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