Having some trouble figuring out a keyboard matrix

Status
Not open for further replies.

number-g

Member
Hi,

I've been following this guide (http://www.instructables.com/id/Make-Any-Vintage-Keyboard-Work-With-a-Modern-PC/) to convert an old laptop keyboard to USB using a Teensy LC.

I've managed to trace and record the keyboard matrix into a spreadsheet (here: https://pastebin.com/NL66Zg2v) but the configuration of the matrix that I have is a bit different from the one on the above guide.

The matrix is 12x12 but isn't symmetrical/sequential: pins 1,2,3,4,5,6,7,8,9,14,15,18 appear to be the rows, and pins 10,11,12,13,16,17,19,20,21,22,23,24 are the columns as opposed to the 8x16 matrix in the above guide which just uses pins 1-8 and 9-16 in sequential order.

I'm confused about how to visualise this and implement it in the code example from the above link. Also I am generally confused about how to "pad" the matrix in the code.

The code from the guide has:
Code:
#include <Keypad.h>

const byte ROWS = 8; //eight rows
const byte COLS = 16; //sixteen columns
char keys[ROWS][COLS] = {
  {'1','2',KEY_ESC,'1',KEY_F4,KEY_G,KEY_PAGE_DOWN,KEY_H,KEY_F7,KEY_F10,KEY_QUOTE,KEY_PAGE_UP,'1',KEY_DOWN,'3','a'},
  {'1',KEY_LEFT_SHIFT,KEY_TAB,KEY_F1,KEY_F3,KEY_T,KEY_RIGHT_BRACE,KEY_Y,KEY_F6,KEY_F9,KEY_LEFT_BRACE,KEY_UP,'1','2','3','a'},
  {'1','2','3','1',KEY_F2,KEY_5,KEY_EQUAL,KEY_6,KEY_F5,KEY_F8,KEY_MINUS,'3','1',KEY_PRINTSCREEN,'3','a'},
  {'1','2',KEY_1,KEY_2,KEY_3,KEY_4,KEY_LEFT,KEY_7,KEY_8,KEY_9,KEY_0,KEY_SCROLL_LOCK,'1','2','3','a'},
  {'1','2',KEY_Q,KEY_W,KEY_E,KEY_R,KEY_EQUAL,KEY_U,KEY_I,KEY_O,KEY_P,'3',KEY_END,KEY_HOME,'3','a'},
  {'1','2',KEY_A,KEY_S,KEY_D,KEY_F,'1',KEY_J,KEY_K,KEY_L,KEY_SEMICOLON,KEY_BACKSLASH,KEY_RIGHT,'2','3','a'},
  {'1',KEY_RIGHT_SHIFT,KEY_Z,KEY_X,KEY_C,KEY_V,KEY_ENTER,KEY_M,KEY_COMMA,KEY_PERIOD,KEY_SLASH,'3','1','2','3','a'},
  {'1','2',KEY_CAPS_LOCK,'1','2',KEY_B,KEY_SPACE,KEY_N,KEY_TILDE,KEY_INSERT,KEY_DELETE,KEY_BACKSPACE,'1','2',KEY_A,'z'}

  };

byte rowPins[ROWS] = {1,2,3,4,5,6,7,8}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24}; //connect to the column pinouts of the keypad
[full source: https://pastebin.com/MkQiKWYy]

I can see that there is some padding to make each row contain 16 items but I don't follow the logic used to get there.

Here's my modified code:
Code:
#include <Keypad.h>

const byte ROWS = 12; // 12 rows
const byte COLS = 12; // 12 columns
const char * keys [ROWS] [COLS] = {

  {0,"KEY_ENTER",0,"KEYPAD_BACKSLASH","KEY_RIGHT_BRACE","KEY_QUOTE","KEYPAD_SLASH",0,0,"KEY_DOWN",0,0},
  {"KEY_RIGHT","KEY_LEFT",0,"KEY_BACKSPACE","KEY_PRINTSCREEN","KEY_LEFT_BRACE","KEY_SEMICOLON","KEY_PERIOD",0,0,"MODIFIERKEY_RIGHT_CTRL","KEY_C"},
  {"KEY_UP",0,0,0,"KEY_P","KEY_PLUS",0,"KEY_L","KEY_COMMA","KEY_X",0,"KEY_Z"},
  {"KEY_INSERT","KEY_MINUS","KEY_O","KEY_K","KEY_M","KEY_N","KEY_B","KEY_V","KEY_S",0,0,0},
  {"KEY_I","KEY_PAUSE","KEY_0","KEY_H","KEY_G","KEY_F","KEY_D","KEY_S","KEY_A","MODIFIERKEY_CTRL",0,0},
  {"KEY_NUM_LOCK","KEY_9","KEY_U","KEY_Y","KEY_T","KEY_R","KEY_E","KEY_W","KEY_Q","KEY_TAB",0,0},
  {"KEY_F10",0,"KEY_7","KEY_8","KEY_6","KEY_5","KEY_4","KEY_3","KEY_2","KEY_1","KEY_TILDE",0},
  {"KEY_F8","KEY_F7","KEY_F6","KEY_F5","KEY_F4","KEY_F3","KEY_F2","KEY_F1","KEY_ESC",0,0,0},
  {"KEY_DEL",0,0,0,0,0,"KEY_F9",0,0,0,0,0},
  {"MODIFIERKEY_RIGHT_SHIFT",0,0,0,0,0,0,0,0,0,0,0},
  {"MODIFIERKEY_LEFT_ALT",0,0,0,0,0,0,0,0,0,0,0},
  {"KEY_CAPS_LOCK",0,"MODIFIERKEY_LEFT_SHIFT","MODIFIERKEY_RIGHT_ALT",0,"KEY_SPACE",0,0,0,0,0,0},
  
  };

byte rowPins[ROWS] = {1,2,3,4,5,6,7,8,9,14,15,18}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {10,11,12,13,16,17,19,20,21,22,23,24}; //connect to the column pinouts of the keypad
[full source: https://pastebin.com/JpQjMTeR]

The zeroes are my attempt at making sense of how to pad it out to make 12 items on each row, and it doesn't work. Also, note the changed rowPins and colPins to reflect my pinout. Not sure if this is correct.

I had to change the keys variable from "char" to "const char *" to get this to compile, I think it's still doing the same job though?

Any help or insight into this would be greatly appreciated.
 
Last edited:
If it were me, I would probably try to make an updated spreadsheet with two dimensions showed.

That is have a set of rows going down for the pins: 1-9
Then setup a set of columns with each unique value that you have in the 2nd numbers, and see just how many columns you need.

Looks like some of the special keys have their own setups (shift, alt....), which I would probably handle seperately.

Then once you know how many unique rows/columns you need, you should be able to assign pins on the LC to each of these...


UPdate: I did not do the whole list but the array starts to look like:
Code:
	1	2	6	8	9	10	11	12	13	14	15	16	17	18
1				Enter	\		]	"	/			Down		
2	right	left			back	prtscr	[	;	.			R-CTRL	c	
3		UP			p	+		l	,			x		z
4					ins	minus	o	k	m	n	b	v	s	
5				i	pause	0		h	g	f	d	s	a	ctrl
6					numlock	9	u	y	t	r	e	w	q	tab
7			f10	7		8	6	5	4	3	2	1

I did not do the coplete list as it goes on to rows 8 and 9...
 
Last edited:
Thanks for your reply,

I realised that I was reading the data in my spreadsheet the wrong way round (that and that some of it was actually wrong in the first place) and that I am actually dealing with an 8x16 matrix.

Pic: https://i.imgur.com/qRb7Tss.png

I figured out how to lay it out properly in the code:
Code:
char keys [ROWS] [COLS] = {

  {MODIFIERKEY_ALT,KEY_RIGHT,'0','0','0','0','0','0'},
  {'0','0',KEY_UP,'0','0','0','0',KEY_CAPS_LOCK},
  {'0','0',KEY_DELETE,'0','0','0','0','0'},
  {'0','0','0','0','0','0','0',MODIFIERKEY_SHIFT},
  {'0','0','0','0','0','0',KEY_F10,'0'},
  {KEY_ENTER,'0','0','0','0',KEY_I,KEY_7,KEY_F9},
  {KEY_BACKSLASH,KEY_BACKSPACE,KEY_P,KEY_INSERT,KEY_PAUSE,KEY_NUM_LOCK,'0','0'},
  {'0',KEY_PRINTSCREEN,KEYPAD_PLUS,KEY_MINUS,KEY_0,KEY_9,KEY_8,KEY_F8},
  {KEY_RIGHT_BRACE,KEY_LEFT_BRACE,'0',KEY_O,'0',KEY_U,KEY_6,KEY_F7},
  {KEY_QUOTE,KEY_SEMICOLON,KEY_L,KEY_K,KEY_H,KEY_Y,KEY_5,KEY_F6},
  {KEY_SLASH,KEY_PERIOD,KEY_COMMA,KEY_M,KEY_G,KEY_T,KEY_4,KEY_F5},
  {MODIFIERKEY_RIGHT_SHIFT,'0',MODIFIERKEY_RIGHT_ALT,KEY_N,KEY_F,KEY_R,KEY_3,KEY_F4},
  {'0',KEY_LEFT,'0',KEY_B,'0',KEY_E,KEY_2,KEY_F3},
  {KEY_DOWN,MODIFIERKEY_RIGHT_CTRL,KEY_SPACE,KEY_V,KEY_D,KEY_W,KEY_1,KEY_F2},
  {'0',KEY_C,KEY_X,KEY_S,KEY_A,KEY_Q,KEY_TILDE,KEY_F1},
  {'0','0',KEY_Z,'0',MODIFIERKEY_CTRL,KEY_TAB,'0',KEY_ESC}

};

Full source: https://pastebin.com/MTNE7sju

The code isn't compiling though, nor is the original code from the guide I have been following. I am getting the following errors.
Code:
keyboard_usb:29: error: narrowing conversion of '57348' from 'int' to 'char' inside { } [-Wnarrowing]
 };
 ^
keyboard_usb:29: error: narrowing conversion of '61519' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61522' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61497' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61516' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '57346' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61507' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61480' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61452' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61476' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61506' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61489' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61482' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61459' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61513' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61512' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61523' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61510' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61527' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61485' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61479' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61478' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61477' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61505' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61488' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61487' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61458' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61464' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61475' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61504' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61492' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61491' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61455' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61454' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61451' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61468' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61474' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61503' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61496' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61495' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61494' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61456' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61450' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61463' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61473' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61502' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '57376' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '57408' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61457' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61449' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61461' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61472' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61501' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61520' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61445' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61448' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61471' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61500' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61521' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '57360' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61484' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61465' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61447' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61466' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61470' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61499' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61446' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61467' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61462' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61444' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61460' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61493' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61498' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61469' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '57345' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61483' from 'int' to 'char' inside { } [-Wnarrowing]
keyboard_usb:29: error: narrowing conversion of '61481' from 'int' to 'char' inside { } [-Wnarrowing]
narrowing conversion of '57348' from 'int' to 'char' inside { } [-Wnarrowing]

I seem to remember reading somewhere that narrowing conversions were previously just considered warnings so it would have compiled in the past but now they are considered actual errors, is there any truth to that?

Presumably the code from the instructable guide did compile at some point on some setup ...
 
Yes,

All of those constants have things like 0xFF00 ored onto them, which won't fit into a byte...

I had something similar with this in the USB Host code and we had a macro which reduced these to a byte... I did a quick and dirty edit of your code and it compiles:

Code:
/*
 * Zenith Supersport 286 Keyboard interpreter 
 */

#include <Keypad.h>

const byte ROWS = 16;
const byte COLS = 8;
#ifdef M
#undef M
#endif
#define M(n) ((n) & KEYCODE_MASK)

char keys [ROWS] [COLS] = {

  {M(MODIFIERKEY_ALT),M(KEY_RIGHT),0,0,0,0,0,0},
  {0,0,M(KEY_UP),0,0,0,0,M(KEY_CAPS_LOCK)},
  {0,0,M(KEY_DELETE),0,0,0,0,0},
  {0,0,0,0,0,0,0,M(MODIFIERKEY_SHIFT)},
  {0,0,0,0,0,0,M(KEY_F10),0},
  {M(KEY_ENTER),0,0,0,0,M(KEY_I),M(KEY_7),M(KEY_F9)},
  {M(KEY_BACKSLASH),M(KEY_BACKSPACE),M(KEY_P),M(KEY_INSERT),M(KEY_PAUSE),M(KEY_NUM_LOCK),0,0},
  {0,M(KEY_PRINTSCREEN),M(KEYPAD_PLUS),M(KEY_MINUS),M(KEY_0),M(KEY_9),M(KEY_8),M(KEY_F8)},
  {M(KEY_RIGHT_BRACE),M(KEY_LEFT_BRACE),0,M(KEY_O),0,M(KEY_U),M(KEY_6),M(KEY_F7)},
  {M(KEY_QUOTE),M(KEY_SEMICOLON),M(KEY_L),M(KEY_K),M(KEY_H),M(KEY_Y),M(KEY_5),M(KEY_F6)},
  {M(KEY_SLASH),M(KEY_PERIOD),M(KEY_COMMA),M(KEY_M),M(KEY_G),M(KEY_T),M(KEY_4),M(KEY_F5)},
  {M(MODIFIERKEY_RIGHT_SHIFT),0,M(MODIFIERKEY_RIGHT_ALT),M(KEY_N),M(KEY_F),M(KEY_R),M(KEY_3),M(KEY_F4)},
  {0,M(KEY_LEFT),0,M(KEY_B),0,M(KEY_E),M(KEY_2),M(KEY_F3)},
  {M(KEY_DOWN),M(MODIFIERKEY_RIGHT_CTRL),M(KEY_SPACE),M(KEY_V),M(KEY_D),M(KEY_W),M(KEY_1),M(KEY_F2)},
  {0,M(KEY_C),M(KEY_X),M(KEY_S),M(KEY_A),M(KEY_Q),M(KEY_TILDE),M(KEY_F1)},
  {0,0,M(KEY_Z),0,M(MODIFIERKEY_CTRL),M(KEY_TAB),0,M(KEY_ESC)}

};

byte rowPins[ROWS] = {0,1,2,3,5,7,8,9,10,11,12,13,14,15,16,17}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {4,6,18,19,20,21,22,23}; //connect to the column pinouts of the keypad


//byte rowPins[ROWS] = {1,2,3,4,6,8,9,10,11,12,13,14,15,16,17,18}; //connect to the row pinouts of the keypad
//byte colPins[COLS] = {5,7,19,20,21,22,23,24}; //connect to the column pinouts of the keypad

Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

unsigned long loopCount;
unsigned long startTime;
String msg;
int x = 0;

void setup() {
    Serial.begin(9600);
    loopCount = 0;
    startTime = millis();
    msg = "";
}


void loop() {
    loopCount++;
    //char key = kpd.getKey();
    if ( (millis()-startTime)>5000 ) {
        Serial.print("Average loops per second = ");
        Serial.println(loopCount/5);
        startTime = millis();
        loopCount = 0;
    }
    
    
    // Fills kpd.key[ ] array with up-to 10 active keys.
    // Returns true if there are ANY active keys.
    if (kpd.getKeys())
    {
        for (int i=0; i<LIST_MAX; i++)   // Scan the whole key list.
        {
            if ( kpd.key[i].stateChanged )   // Only find keys that have changed state.
            {
                switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
                    case PRESSED:
                    msg = " PRESSED.";

                    
                    
                    Serial.print("Key ");
                Serial.print(kpd.key[i].kchar);
                Serial.println(msg);
                // release all the keys at the same instant
                 Keyboard.set_key1(kpd.key[i].kchar);
                Keyboard.send_now();
               
                //Keyboard.set_key1(0);
                //Keyboard.send_now();
                if (kpd.key[i].kchar == char(M(KEY_LEFT_SHIFT))) {
                  Serial.print("Shift ");
                  Keyboard.set_modifier(M(MODIFIERKEY_SHIFT));
                  Keyboard.send_now();
                  x=1;
             
        }
        
                break;
                 
                    case HOLD:
                    msg = " HOLD.";
                    //Keyboard.set_modifier(M(MODIFIERKEY_SHIFT));
                    //Keyboard.send_now();
                    
                    Keyboard.set_key1(kpd.key[i].kchar);
                Keyboard.send_now();
                    
                break;
                    case RELEASED:
                    msg = " RELEASED.";
                    Serial.println(msg);
                    Keyboard.set_key1(0);
                Keyboard.send_now();
                if (kpd.key[i].kchar == char(M(KEY_LEFT_SHIFT))) {
                  Serial.print("Shift Released ");
                  Keyboard.set_modifier(0);
                  Keyboard.send_now();
                  x=0;
                }
               
                break;
                    case IDLE:
                    msg = " IDLE.";
                    
                }
                
            }
        }
    }
}  // End
 
Hi,

Thanks again for your help, I appreciate it.

It compiles!

But I think I had my matrix the wrong way around (16x8 as opposed to 8x16) as it was going kind of berserk until I changed to 8x16. Now it compiles but doesn't send the right keystrokes, I am assuming due to my pinout in the code. I don't quite understand how to correlate my matrix with the pins.

Here's what I have:
Untitled.jpg

How do i reconcile the fact that pin 8 (for example) on the keyboard is used as both a row and a column? (see picture).

Code:
byte rowPins[ROWS] = {5,7,19,20,21,22,23,24}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {1,2,3,4,6,8,9,10,11,12,13,14,15,16,17,18}; //connect to the column pinouts of the keypad

Am I even in the right ballpark with this or am I totally misunderstanding something?

EDIT: Come to think of it, 18 is the highest pin in use at all, there were 24 on the board so I connected them all but I guess I don't even need the other 6? Or would they be used for something else while the keyboard is operational?
 
Last edited:
Sorry hard for me to know how your keyboard is actually hooked up internally. Yes having Rows/Columns using same pin I would believe would be problematic.

Again I have not used this library, but long time ago rolled my own using 16 button keypad, plus hard wired in an extra row of buttons.
 
Scratch that, my matrix is still a little bit off. My multimeter probes broke while I was halfway through it the first time around so I have been using whatever was to hand, gripped with croc clips and must've made a few mistakes. I'll update this when I get a bit more time to re-check everything.
 
Status
Not open for further replies.
Back
Top