16button Push box

Hi everyone,

I’m trying to make my own ‘Stream Deck’ and so far I’ve managed to solder it all up and got it all ready, I have utilized some codes i’ve found on the internet to try and test it but it doesn’t seem to be responding at all to it.

I am using a 4 row 4 cols matrix. And buttons are just bog standard arcade style buttons.

Pins connected are 10, 16,14,15 for cols and 18,19,20,21 for rows.

I’m pretty sure theres nothing wrong with the soldering so I can only put it down to the board not liking the code.

//Rydema Button Box
//This is my cheap alternative to a Stream Deck by Elgato
void setup() {
}
#include <Keyboard.h>
#include <Keypad.h>

#define ENABLE_PULLUPS
#define NUMBUTTONS 16
#define NUMROWS 4
#define NUMCOLS 4

const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
  {'F13','F14','F15','F16'},
};

byte rowPins[ROWS] = {10, 16, 14, 15};
byte colPins[COLS] = {18, 19, 20, 21};

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

void loop(){
  keypad.getKey();
}

You may only put a single character between single quotes. 'F13' is illegal.

If you are going to define an array as having 16 elements (4 rows and 4 columns) then it would be expected that you would provide 16 (and not 4) initial values.

This program provides no responses so if you are getting no response perhaps it is working correctly. :)

vaj4088: You may only put a single character between single quotes. 'F13' is illegal.

If you are going to define an array as having 16 elements (4 rows and 4 columns) then it would be expected that you would provide 16 (and not 4) initial values.

This program provides no responses so if you are getting no response perhaps it is working correctly. :)

I'm trying to program it so that the button comes up and utilises OBS shortcut functions

Is there a way of saying 1,2,3,4 are F13 14 etc?

Like saying these buttons keyboard.press('f13')

Is there a way of saying 1,2,3,4 are F13 14 etc?

Yes. Have the buttons send 'A' to 'P', subtract 65 from what they send to get 0 to 15 and use the value as an index to an array of strings.

UKHeliBob: Yes. Have the buttons send 'A' to 'P', subtract 65 from what they send to get 0 to 15 and use the value as an index to an array of strings.

Sorry for asking but i'm still relatively new to coding

How would that look in terms of the code above?

How would that look in terms of the code above?

char keys[ROWS][COLS] = {
  {  0,   1,   2,  3},
  {  4,   5,   6,  7},
  {  8,   9, 10, 11},
  {12, 13, 14, 15}
};
void loop(){
  keypad.getKey();
}

It is pointless to call the getKey() function when you don’t give a rat’s ass what key is pressed.

void loop()
{
  byte key = keypad.getKey();
  if(key != NO_KEY)
  {
     // I'm willing to guess that you can figure out the rest of the code
     // The value in key will be between 0 and 15 inclusive
  }
}

PaulS: char keys[ROWS][COLS] = {   {  0,  1,  2,  3},   {  4,  5,  6,  7},   {  8,  9, 10, 11},   {12, 13, 14, 15} };

void loop(){
  keypad.getKey();
}

It is pointless to call the getKey() function when you don't give a rat's ass what key is pressed.

void loop()
{
  byte key = keypad.getKey();
  if(key != NO_KEY)
  {
     // I'm willing to guess that you can figure out the rest of the code
     // The value in key will be between 0 and 15 inclusive
  }
}

Legendary! Thank you very much I really appreciate it.

Hopefulyl this will solve my problem and if not.... back to the drawing board... also wondering if the cable i bought is too thing for what it requires.

also wondering if the cable i bought is too thing for what it requires.

Well, I'm wondering what you are talking about...

If that was supposed to be "thick" rather than "thing", then, no. A wire can not be too large. It can be too small.

PaulS: Well, I'm wondering what you are talking about...

If that was supposed to be "thick" rather than "thing", then, no. A wire can not be too large. It can be too small.

Thin... I meant thin x)

PaulS:
Well, I’m wondering what you are talking about…

If that was supposed to be “thick” rather than “thing”, then, no. A wire can not be too large. It can be too small.

Not going to lie. I’m at a loose end. I thought I knew But I don’t :frowning: I have tried a few different variables from codes all over the shop and so far my results have come up not good, it either doesn’t function or doesn’t do on press (meaning it keeps typing 3)

UKHeliBob: Yes. Have the buttons send 'A' to 'P', subtract 65 from what they send to get 0 to 15 and use the value as an index to an array of strings.

Any ideas ?

Any ideas ?

Ideas about what ?

Where are you stuck ?

Paul's suggested solution was a neater version of mine. Which solution are you using ?

Have you got a value between 0 and 15 as a result of pressing a button on the keypad ?

UKHeliBob: Ideas about what ?

Where are you stuck ?

Paul's suggested solution was a neater version of mine. Which solution are you using ?

Have you got a value between 0 and 15 as a result of pressing a button on the keypad ?

I adjusted the code to Pauls but when I went to add the buttons nothing seems to work, I was certain it was if(key !== 0){ keyboard.press(KEY_F13); }

If what you tried had worked then no matter which button was pressed apart from 0 the the KEY_F13 keypress would have been sent. Is that what you intended ?

As it happens you have got the test syntax wrong. Use either != or == but not a combination of both

UKHeliBob: If what you tried had worked then no matter which button was pressed apart from 0 the the KEY_F13 keypress would have been sent. Is that what you intended ?

As it happens you have got the test syntax wrong. Use either != or == but not a combination of both

Basically The matrix is literally arcade style buttons, 4 buttons long (row) 4 rows down (cols)

And i've weird is so that it's a matrix only using 8 pins total one side of the board (10,16,14,15,A0,A1,A2,A3)

So the idea is that when I press button2 of row 3 col 2 it to press what ever key i've programmed i.e F13

4 buttons across and 4 buttons down equals 16 buttons. No surprise that it only uses 8 buttons then

So the idea is that when I press button2 of row 3 col 2 it to press what ever key i’ve programmed i.e F13

Stage 1 : print the value returned by the keypad. Post your complete code here that reads the keyboard and prints what is returned.

UKHeliBob: 4 buttons across and 4 buttons down equals 16 buttons. No surprise that it only uses 8 buttons then

Stage 1 : print the value returned by the keypad. Post your complete code here that reads the keyboard and prints what is returned.

Thats the problem... Press button and nothing happens.... at all, not even in the serial console.

Post the code as it is now

UKHeliBob: Post the code as it is now

Will do soon as I get home! I finish at 6GMT takes 30 mins to get home depending on traffic.

UKHeliBob:
Post the code as it is now

//Rydema Button Box
//This is my cheap alternative to a Stream Deck by Elgato
#include <Keyboard.h>

void setup() {
Serial.begin(9600);
pinMode(10,INPUT_PULLUP);
pinMode(16,INPUT_PULLUP);
pinMode(14,INPUT_PULLUP);
pinMode(15,INPUT_PULLUP);
pinMode(A0,INPUT_PULLUP);
pinMode(A1,INPUT_PULLUP);
pinMode(A2,INPUT_PULLUP);
pinMode(A3,INPUT_PULLUP);
}

#include <Keypad.h>

#define ENABLE_PULLUPS

const byte ROWS = 4;
const byte COLS = 4;
char keys[4][4] = {
  {'0','1','2','3'},
  {'4','5','6','7'},
  {'8','9','A','B'},
  {'C','D','E','F'}
};

byte rowPins[ROWS] = {10, 16, 14, 15};
byte colPins[COLS] = {A0, A1, A2, A3};

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

void loop()
{ while(digitalRead(10) == HIGH){
  delay(500);
}
  byte key = keypad.getKey();
  if(key != NO_KEY)
  {
    Serial.println(key);
  }
  if(key != 0){
    Keyboard.press(KEY_F13);
    delay(500);
    Keyboard.releaseAll();
    delay(500);
  }
}