Button matrix characters assigned by user

Hi guys,
I don't really have code to show for my project yet. I have a code base from a MIDIkeyboard project I found that I've started to cannibalize. I'm not married to that piece of code because I don't know that it will do what I want.

I'm probably going to go with this though: Keypad Tutorial.

I'm trying to create a button matrix that can have its character values assigned by a computer.

Here is my wiring so far:

So to be clear, instead of assigning which button will show which character, I would like to have a way of assigning them as I need them.

Would something like that be possible?

Thank you,

char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'#','0','*'}
};

This 2D array assigns the character that is shown (its value) to a key. You can write to this array and change (assign) the value of a particular key any time. So for instance you want to have a 'X' where the '6' is. Since it is a char array, you can only assign one character per key.

Demo code:

const byte ROWS = 4; // Four rows
const byte COLS = 3; // Three columns

char keys[ROWS][COLS] = {
  {'1', '2', '3'},
  {'4', '5', '6'},
  {'7', '8', '9'},
  {'#', '0', '*'}
};

void setup()
{
  Serial.begin(9600);
  // print the existing array
  for (int n = 0; n < COLS; n++)
  {
    for (int m = 0; m < ROWS; m++)
    {
      Serial.print(keys[n][m]);
      Serial.print("   ");
    }
  }
  Serial.println();
  // now replace the '6' with 'X'
  keys[1][2] = 'X';  // replace element row 1, column 2 with 'X'
  // print the modified array
  for (int n = 0; n < COLS; n++)
  {
    for (int m = 0; m < ROWS; m++)
    {
      Serial.print(keys[n][m]);
      Serial.print("   ");
    }
  }
  Serial.println();   
}

void loop()
{
  
}

Is that what you meant?

Hello GroundFugnus,
I believe that is what I mean. I wasn't aware that I could change the value. I thought I had to specify it in the code.

I'll give that a try.

Thank you!

Actually, I hadn't read the code till now. Basically, I am making a USB controller. I want to be able to change the keys from the computer to the inputs of a game.

I guess I would have to write a driver or something?

This project might be more than I can chew for a first project..

I also need the ability to press any number of keys at the same time, that's why I am using a 74HC595 shift register.

Any further help would be appreciated.

Thank you.

The picture that shows your wiring does not show in my browser (Chrome). Here is a guide for posting images.
I don't really understand what you are trying to do. The schematic will help but can you describe your project in more detail?

I fixed my reply so you can see the image. It would have worked if you clicked the link but I did intend for it to work here as well.

What I'm doing is; I'm building a USB game controller for Overwatch. I want to include as many keys as possible.

I have put 12 buttons on one side, 4 buttons on the other, a trigger, and a second trigger in front.

I am also including a Gyroscope component to control where you look.

I need to be able to press all the buttons at the same time.

I also want to be able to assign the keys from the computer the controller is plugged into.

I figured a button matrix with a shift register or registers would be best but I don't know how to make them all play nice.

Any and all help is appreciated.

Thank you,

You can use a 32U4 based board like the Leonardo or Micro. It can act as a HID device (keyboard/mouse).

Yes, I have a micro that I am going to use for that but I don't know how to program it to do what I need it to do.

How about this? arduino as usb hid

and this: Arduino keyboard emulator?

But that seems like it will take up a lot of pins. I need a lot of inputs...