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

Thread: Teensy perform some function automatically sometime.out of code

  1. #1

    Teensy perform some function automatically sometime.out of code

    sir ,
    i have use keypad library to add lot of push button.
    these button perform differents keboard & Mouse commands.
    every functions is controlled by use "if" . No any function is written in sketch to do automatically.
    wiring is also correct. No any row is shorted to row or column to column. every push button between row &
    column is connectd wia 1N4148 Doide.

    when any button is pressed, function is being done, which is written for that button.

    sometime it is working fine .But , sometime some functions are being automatically .
    what is wrong here......

    code and my wiring is below.

    Code:
     #include <Keypad.h>                 //   patch press & hold not working,,    remove patch block with new rows funcction
     #include <Encoder.h>
    
    const byte ROWS = 6; //four rows
    const byte COLS = 9; //three columns             // tested ok display Key number
    char keys[ROWS][COLS] = {
    {1,2,3,4,5,6,7,8,9},
    {10,11,12,13,14,15,16,17,18,},
    {19,20,21,22,23,24,25,26,27},
    {28,29,30,31,32,33,34,35,36},
    {37,38,39,40,41,42,43,44,45},                 //   6 x 9
    {46,47,48,49,50,51,52,53,54},
    };
    byte rowPins[ROWS] = {0, 1, 4, 5, 6, 7 }; //connect to the row pinouts of the kpd
    byte colPins[COLS] = { 8, 9,  10, 11, 12, 13, 14, 16, 17}; //connect to the column pinouts of the kpd
    Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
    
    Encoder myEnc(2, 3);     // which pins are connected to Encoder
    
    
    void setup() {
         Mouse.screenSize(1366, 768);  // configure screen size
         Serial.begin(9600);
    
    }
    
    long oldPosition  = -999; 
    
    void loop() {
      // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Encoder begin
      long newPosition = myEnc.read();  
        if (newPosition > oldPosition) {                    
        oldPosition = newPosition;                
         Mouse.moveTo(512, 54);    //  put here action to be, when Encoder is rotated upward  
        Mouse.scroll(+1);          
        Mouse.moveTo(345, 94);
       }
       if (newPosition < oldPosition) {   
        oldPosition = newPosition;       
         Mouse.moveTo(512, 54);     //  put here action to be, when Encoder is rotated Downward   
        Mouse.scroll(-1);          
        Mouse.moveTo(345, 94);
       } 
    //  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Encoder end
        
        
        if (kpd.getKeys())
        {
          
            for (int i=0; i<LIST_MAX; i++)   // Scan the whole key list.
            {
                if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 1))   // ----------------------------------------Tempo UP-----begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                              Mouse.moveTo(512, 54);       // point to pixel at 512, 54
                              Mouse.scroll(+1);           // turn scroll wheel upward 1 step
                              Mouse.moveTo(345, 94);
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
    
                            if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 6))   // -------------------------------Tempo DOWN---begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                                   Mouse.moveTo(512, 54);      // point to pixel at 512, 54
                                   Mouse.scroll(-1);           // turn scroll wheel downward 1 step
                                   Mouse.moveTo(345, 94);
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
                                        if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 2))   // ---------------------------Tempo TAP---begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
        Keyboard.set_modifier(MODIFIERKEY_CTRL);  //Press ctrl  key
        Keyboard.send_now();
        Keyboard.set_key1(KEY_F5);      //Press  F5
        Keyboard.send_now(); 
        Keyboard.set_modifier(0);    // Release  ctrl key
        Keyboard.set_key1(0);       // Release F5
        Keyboard.send_now();
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
                                               if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 8))   // ---------------------------ENTER---begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
        Keyboard.set_key1(KEY_ENTER);      //Press  ENTER
        Keyboard.send_now(); 
        Keyboard.set_key1(0);       // Release ENTER
        Keyboard.send_now();
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
                                                    if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 10))   // ---------------------Pitch UP-------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                                 Mouse.moveTo(357, 36);      // point to pixel at (357, 36)
                                 Mouse.set_buttons(1, 0, 0);  // hold left button
                                 Mouse.moveTo(357, 31);
                                 Mouse.set_buttons(0, 0, 0);  // hold left button
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
                                                               if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 3))   // -------------Pitch DOWN----begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                                       Mouse.moveTo(357, 36);      // point to pixel at (357, 36)
                                       Mouse.set_buttons(1, 0, 0);  // hold left button
                                       Mouse.moveTo(357, 41);
                                       Mouse.set_buttons(0, 0, 0);  // hold left button
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
    
                                                               if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 17))   // -------------F6-------------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                                          Keyboard.set_key1(KEY_F6);  // Press F6
                                          Keyboard.send_now();
                                          Keyboard.set_key1(0);       //Release F6
                                          Keyboard.send_now();
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
    
                                     if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 18))   // ----------------------FOLDER OPEN------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                                 Mouse.moveTo(332, 748);      // point to pixel at (332, 748)  where window exploreler is in taskbar
                                 Mouse.set_buttons(1, 0, 0);  // click
                                 Mouse.set_buttons(0, 0, 0);  // release click
                                 Mouse.moveTo(1050, 233);      // point to pixel at (1050, 233)
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
                                           if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 7))   // ----------------------NO cencal------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
        Keyboard.set_key1(KEY_RIGHT);  
        Keyboard.send_now();
        Keyboard.set_key1(0);       
        Keyboard.send_now();
        Keyboard.set_key1(KEY_ENTER);  
        Keyboard.send_now();
        Keyboard.set_key1(0);       
        Keyboard.send_now();
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
    
                                 if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 16))   // -----------------------NUMERIC (-)------------------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                               Keyboard.set_key1(KEYPAD_MINUS);  // Press -
                               Keyboard.send_now();
                               Keyboard.set_key1(0);       //Release -
                               Keyboard.send_now();
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
    
                                  if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 13))   // ----------------NUMERIC (+)-----------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                                   Keyboard.set_key1(KEYPAD_PLUS);  // Press +
                                   Keyboard.send_now();
                                   Keyboard.set_key1(0);       //Release +
                                   Keyboard.send_now();
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
    
                                  if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 11))   // ----------------------SPACE----------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                              Keyboard.set_key1(KEY_SPACE);   
                              Keyboard.send_now();
                              Keyboard.set_key1(0);        
                              Keyboard.send_now();
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
    
                                  if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 12))   // ----------------BACK SLASH------------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                                 Keyboard.set_key1(KEYPAD_SLASH);  // Press    ( / )
                                 Keyboard.send_now();
                                 Keyboard.set_key1(0);       //Release     ( / )
                                 Keyboard.send_now();
    
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
    
                                   if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 15))   // --------------(VOL+)--------------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                              Keyboard.press(KEY_MEDIA_VOLUME_INC);   
                              Keyboard.release(KEY_MEDIA_VOLUME_INC);
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
    
                                  if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 4))   // -----------------(VOL-)-----------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                                 Keyboard.press(KEY_MEDIA_VOLUME_DEC);   
                                 Keyboard.release(KEY_MEDIA_VOLUME_DEC);
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
    
                                 if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 25))   // -------------------PAT 1  ---------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                                 Keyboard.set_key1(KEYPAD_1);   
                                 Keyboard.send_now();
                                 Keyboard.set_key1(0);        
                                 Keyboard.send_now();
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
    
                                if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 26))   // ------------------PAT 2 ----------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                                 Keyboard.set_key1(KEYPAD_2);   
                                 Keyboard.send_now();
                                 Keyboard.set_key1(0);        
                                 Keyboard.send_now();
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
    
                                if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 27))   // -------------------PAT 3 ---------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                                     Keyboard.set_key1(KEYPAD_3);   
                                     Keyboard.send_now();
                                     Keyboard.set_key1(0);        
                                     Keyboard.send_now();
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
    
                                if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 22))   // -----------------PAT 4 -----------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                                   Keyboard.set_key1(KEYPAD_4);   
                                   Keyboard.send_now();
                                   Keyboard.set_key1(0);        
                                   Keyboard.send_now();
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
    
                                 if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 23))   // ---------------------PAT 5 -------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                               Keyboard.set_key1(KEYPAD_5);   
                               Keyboard.send_now();
                               Keyboard.set_key1(0);        
                               Keyboard.send_now();
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
    
                                if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 24))   // --------------------PAT 6 --------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                               Keyboard.set_key1(KEYPAD_6);   
                               Keyboard.send_now();
                               Keyboard.set_key1(0);        
                               Keyboard.send_now();
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
    
                                   if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 21))   // -------------------PAT 7 ---------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                               Keyboard.set_key1(KEYPAD_7);   
                               Keyboard.send_now();
                               Keyboard.set_key1(0);        
                               Keyboard.send_now();
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
    
                                if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 20))   // ------------------- PAT 8 ---------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                               Keyboard.set_key1(KEYPAD_8);   
                               Keyboard.send_now();
                               Keyboard.set_key1(0);        
                               Keyboard.send_now();
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
    
                                    if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 19))   // --------------------PAT 9--------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                               Keyboard.set_key1(KEYPAD_9);   
                               Keyboard.send_now();
                               Keyboard.set_key1(0);        
                               Keyboard.send_now();
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
    
                                if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 34))   // -------------------PAT 10 ---------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
        Mouse.moveTo(330, 94);      //  Mouse Go to pixel at (330, 94)
        Mouse.set_buttons(1, 0, 0);  // lEFT CLICK
        Mouse.set_buttons(0, 0, 0);
        Mouse.moveTo(330, 288);     //  where  your  Pattern
        Mouse.set_buttons(1, 0, 0);  //  CLICKWERT
        Mouse.set_buttons(0, 0, 0);
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
    
                                 if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 35))   // --------------------PAT 11 --------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
        Mouse.moveTo(330, 94);      //  Mouse Go to pixel at (330, 94)
        Mouse.set_buttons(1, 0, 0);  // lEFT CLICK
        Mouse.set_buttons(0, 0, 0);
        Mouse.moveTo(338, 306);     //  where  your  Pattern
        Mouse.set_buttons(1, 0, 0);  //  CLICK
        Mouse.set_buttons(0, 0, 0);
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
    
                                    if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 36))   // ------------------PAT 12----------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
        Mouse.moveTo(330, 94);      //  Mouse Go to pixel at (330, 94)
        Mouse.set_buttons(1, 0, 0);  // lEFT CLICK
        Mouse.set_buttons(0, 0, 0);
        Mouse.moveTo(338, 325);     //  where  your  Pattern
        Mouse.set_buttons(1, 0, 0);  //  CLICK
        Mouse.set_buttons(0, 0, 0);
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
    
                                   if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 31))   // --------------------PAT 13--------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
        Mouse.moveTo(330, 94);      //  Mouse Go to pixel at (330, 94)
        Mouse.set_buttons(1, 0, 0);  // lEFT CLICK
        Mouse.set_buttons(0, 0, 0);
        Mouse.moveTo(338, 344);     //  where  your  Pattern
        Mouse.set_buttons(1, 0, 0);  //  CLICK
        Mouse.set_buttons(0, 0, 0);
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
    
                                  if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 32))   // ----------------------PAT 14------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
        Mouse.moveTo(330, 94);      //  Mouse Go to pixel at (330, 94)
        Mouse.set_buttons(1, 0, 0);  // lEFT CLICK
        Mouse.set_buttons(0, 0, 0);
        Mouse.moveTo(338, 364);     //  where  your  Pattern
        Mouse.set_buttons(1, 0, 0);  //  CLICK
        Mouse.set_buttons(0, 0, 0);
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
    
                               if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 33))   // --------------------PAT 15--------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
        Mouse.moveTo(330, 94);      //  Mouse Go to pixel at (330, 94)
        Mouse.set_buttons(1, 0, 0);  // lEFT CLICK
        Mouse.set_buttons(0, 0, 0);
        Mouse.moveTo(338, 383);     //  where  your  Pattern
        Mouse.set_buttons(1, 0, 0);  //  CLICK
        Mouse.set_buttons(0, 0, 0);
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
    
                                 if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 30))   // --------------------PAT 16--------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
        Mouse.moveTo(330, 94);      //  Mouse Go to pixel at (330, 94)
        Mouse.set_buttons(1, 0, 0);  // lEFT CLICK
        Mouse.set_buttons(0, 0, 0);
        Mouse.moveTo(338, 402);     //  where  your  Pattern
        Mouse.set_buttons(1, 0, 0);  //  CLICK
        Mouse.set_buttons(0, 0, 0);
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
    
                                             if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 29))   // --------------------PAT 17--------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
        Mouse.moveTo(330, 94);      //  Mouse Go to pixel at (330, 94)
        Mouse.set_buttons(1, 0, 0);  // lEFT CLICK
        Mouse.set_buttons(0, 0, 0);
        Mouse.moveTo(338, 421);     //  where  your  Pattern
        Mouse.set_buttons(1, 0, 0);  //  CLICK
        Mouse.set_buttons(0, 0, 0);
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
    
                                             if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 28))   // --------------------PAT 18--------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
        Mouse.moveTo(330, 94);      //  Mouse Go to pixel at (330, 94)
        Mouse.set_buttons(1, 0, 0);  // lEFT CLICK
        Mouse.set_buttons(0, 0, 0);
        Mouse.moveTo(338, 439);     //  where  your  Pattern
        Mouse.set_buttons(1, 0, 0);  //  CLICK
        Mouse.set_buttons(0, 0, 0);
                    break;
                        case HOLD:
                       //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // *********************************************************************************************************************end 1
    
                                             if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 43))   // --------------------Patch 1 --------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                                        Mouse.moveTo(275,135);      //  Mouse Go to pixel at (330, 94)
                                        Mouse.set_buttons(1, 0, 0);  // lEFT CLICK
                                        Mouse.set_buttons(0, 0, 0);
                    break;
                        case HOLD:
                             //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // ***************************************************************************************************************Patch******end 1
                                                         if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 44))   // --------------------Patch 2 --------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                                        Mouse.moveTo(275,167);      //  Mouse Go to pixel at (330, 94)
                                        Mouse.set_buttons(1, 0, 0);  // lEFT CLICK
                                        Mouse.set_buttons(0, 0, 0);
                    break;
                        case HOLD:
                             //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // ***************************************************************************************************************Patch******end 1
                                                         if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 45))   // --------------------Patch 3 --------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                                        Mouse.moveTo(275,195);      //  Mouse Go to pixel at (330, 94)
                                        Mouse.set_buttons(1, 0, 0);  // lEFT CLICK
                                        Mouse.set_buttons(0, 0, 0);
                    break;
                        case HOLD:
                             //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // ***************************************************************************************************************Patch******end 1
                                                         if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 40))   // --------------------Patch 4 --------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                                        Mouse.moveTo(275,227);      //  Mouse Go to pixel at (330, 94)
                                        Mouse.set_buttons(1, 0, 0);  // lEFT CLICK
                                        Mouse.set_buttons(0, 0, 0);
                    break;
                        case HOLD:
                             //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // ***************************************************************************************************************Patch******end 1
                                                         if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 41))   // --------------------Patch 5 --------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                                        Mouse.moveTo(275,257);      //  Mouse Go to pixel at (330, 94)
                                        Mouse.set_buttons(1, 0, 0);  // lEFT CLICK
                                        Mouse.set_buttons(0, 0, 0);
                    break;
                        case HOLD:
                             //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // ***************************************************************************************************************Patch******end 1
                                                         if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 42))   // --------------------Patch 6 --------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                                        Mouse.moveTo(275,286);      //  Mouse Go to pixel at (330, 94)
                                        Mouse.set_buttons(1, 0, 0);  // lEFT CLICK
                                        Mouse.set_buttons(0, 0, 0);
                    break;
                        case HOLD:
                             //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // ***************************************************************************************************************Patch******end 1
                                                         if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 39))   // --------------------Patch 7 --------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                                        Mouse.moveTo(275,317);      //  Mouse Go to pixel at (330, 94)
                                        Mouse.set_buttons(1, 0, 0);  // lEFT CLICK
                                        Mouse.set_buttons(0, 0, 0);
                    break;
                        case HOLD:
                             //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // ***************************************************************************************************************Patch******end 1
                                                         if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 38))   // --------------------Patch 8 --------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                                        Mouse.moveTo(275,347);      //  Mouse Go to pixel at (330, 94)
                                        Mouse.set_buttons(1, 0, 0);  // lEFT CLICK
                                        Mouse.set_buttons(0, 0, 0);
                    break;
                        case HOLD:
                             //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // ***************************************************************************************************************Patch******end 1
                                                         if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 37))   // --------------------Patch 9 --------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                                        Mouse.moveTo(275,377);      //  Mouse Go to pixel at (330, 94)
                                        Mouse.set_buttons(1, 0, 0);  // lEFT CLICK
                                        Mouse.set_buttons(0, 0, 0);
                    break;
                        case HOLD:
                             //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // ***************************************************************************************************************Patch******end 1
                                                         if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 52))   // --------------------Patch 10 --------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                                        Mouse.moveTo(275,408);      //  Mouse Go to pixel at (330, 94)
                                        Mouse.set_buttons(1, 0, 0);  // lEFT CLICK
                                        Mouse.set_buttons(0, 0, 0);
                    break;
                        case HOLD:
                             //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // ***************************************************************************************************************Patch******end 1
                                                         if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 53))   // --------------------Patch 11 --------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                                        Mouse.moveTo(275,437);      //  Mouse Go to pixel at (330, 94)
                                        Mouse.set_buttons(1, 0, 0);  // lEFT CLICK
                                        Mouse.set_buttons(0, 0, 0);
                    break;
                        case HOLD:
                             //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // ***************************************************************************************************************Patch******end 1
                                                         if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 54))   // --------------------Patch 12 --------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                                        Mouse.moveTo(275,468);      //  Mouse Go to pixel at (330, 94)
                                        Mouse.set_buttons(1, 0, 0);  // lEFT CLICK
                                        Mouse.set_buttons(0, 0, 0);
                    break;
                        case HOLD:
                             //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // ***************************************************************************************************************Patch******end 1
                                                         if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 49))   // --------------------Patch 13 --------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                                        Mouse.moveTo(275,498);      //  Mouse Go to pixel at (330, 94)
                                        Mouse.set_buttons(1, 0, 0);  // lEFT CLICK
                                        Mouse.set_buttons(0, 0, 0);
                    break;
                        case HOLD:
                             //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // ***************************************************************************************************************Patch******end 1
                                                         if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 32 ))   // --------------------Patch 14 --------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                                        Mouse.moveTo(275,528);      //  Mouse Go to pixel at (330, 94)
                                        Mouse.set_buttons(1, 0, 0);  // lEFT CLICK
                                        Mouse.set_buttons(0, 0, 0);
                    break;
                        case HOLD:
                             //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // ***************************************************************************************************************Patch******end 1
                                                         if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 51))   // --------------------Patch 15 --------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                                        Mouse.moveTo(275,558);      //  Mouse Go to pixel at (330, 94)
                                        Mouse.set_buttons(1, 0, 0);  // lEFT CLICK
                                        Mouse.set_buttons(0, 0, 0);
                    break;
                        case HOLD:
                             //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // ***************************************************************************************************************Patch******end 1
                                                         if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 48))   // --------------------Patch 16 --------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                                        Mouse.moveTo(275,586);      //  Mouse Go to pixel at (330, 94)
                                        Mouse.set_buttons(1, 0, 0);  // lEFT CLICK
                                        Mouse.set_buttons(0, 0, 0);
                    break;
                        case HOLD:
                             //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // ***************************************************************************************************************Patch******end 1
                                                         if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 47))   // --------------------Patch 17 --------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                                        Mouse.moveTo(275,616);      //  Mouse Go to pixel at (330, 94)
                                        Mouse.set_buttons(1, 0, 0);  // lEFT CLICK
                                        Mouse.set_buttons(0, 0, 0);
                    break;
                        case HOLD:
                             //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // ***************************************************************************************************************Patch******end 1
                                                         if (( kpd.key[i].stateChanged ) && (kpd.key[i].kchar == 46))   // --------------------Patch 18 --------begin 1
                {
                    switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                        case PRESSED:
                                        Mouse.moveTo(275,650);      //  Mouse Go to pixel at (330, 94)
                                        Mouse.set_buttons(1, 0, 0);  // lEFT CLICK
                                        Mouse.set_buttons(0, 0, 0);
                    break;
                        case HOLD:
                             //  Do when Hold
                    break;
                        case RELEASED:
                        //  Do when Released
                    break;
                    /*    case IDLE:
                        //  Do when IDLE     */
                    }
                }  // ***************************************************************************************************************Patch******end 1
                
                
            }
        }
    }
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	teensy wiring n.jpg 
Views:	24 
Size:	92.3 KB 
ID:	14766   Click image for larger version. 

Name:	teensy wiring.jpg 
Views:	24 
Size:	69.8 KB 
ID:	14767  


  2. #2
    Senior Member pictographer's Avatar
    Join Date
    May 2013
    Location
    San Jose, CA
    Posts
    664
    I don't see you setting the input more of any of the pins. You might need to configure the inputs to use pull down resistors so they don't float and give occasional wrong values.

  3. #3
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,235
    Why did you start another thread on your keypad??? you already had an active thread
    https://forum.pjrc.com/threads/53797...keypad-library

    you might check the de-bounce logic in the keypad library.

  4. #4
    Quote Originally Posted by manitou View Post
    Why did you start another thread on your keypad??? you already had an active thread
    https://forum.pjrc.com/threads/53797...keypad-library

    you might check the de-bounce logic in the keypad library.
    In my old Post senior members suggested me to start New thread , when you get solved your issue ,. So I have got solved my previous issue . By using latest teensyduino 1.43. now board is getting new sketches successfully. I am not so familiar to keyboard library & Arduino language.but I will try, what you suggest me .... thanks you....is.my wiring correct????

Posting Permissions

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