Noob Macro Keyboard Trouble

For whatever reason I decided it would be a good idea to build a macro Keyboard. One big problem, I do not know where to start when it comes to programming this thing. I purchased a PCB from Ryan Bates off of tindie.com. I've asked him a few questions do there wasn't much help. His website retrobuiltgames.com has an Expert Code (DIY Arcade Cabinet Kits + more. - Macro Keyboard V2.0), but there are things in this code that I don't want to use and I have no clue what I can remove or not. I do not have encoder switches, lcd display, no LEDs installed on the keyboard. And one thing I would like is instead of using the A0 keyswitch as a mode switch, I want it to be an ESC key. I am wanting to use this as a shortcut keyboard for autocad. I just need help getting the code started, so I can figure it out from there.

Also I have the Arduino (KeyeStudio) Pro Micro soldered onto the PCB. I have 10 ZugGear (MX Cherry) keys installed, plan to get more so I have each slot filled.

Now when I say I don't have LED's installed, I mean soldered on the board and controlled off of the PCB. I had some LED strip lights from a different project that I decided to throw in the case. I soldered them to a 2.1 DC Jack with a 12V adapter.



On that page is the source for:

Example Code: Simple Macros, LCD and RGB LED support.

Fortunately, you can just copy the text from that page and paste it into the Arduino IDE. after ripping out the LCD, Encoder, and NeoPixel stuff you are left with:

// --------------------------------------------------------------
// Standard Libraries
// --------------------------------------------------------------
#include <Keyboard.h>  // USB HID Keyboard (Leonardo or Micro)
#include <Keypad.h>
// This library is for interfacing with the 3x4 Matrix
// Can be installed from the library manager, search for "keypad"
// and install the one by Mark Stanley and Alexander Brevig
// https://playground.arduino.cc/Code/Keypad/

const byte ROWS = 3; //four rows
const byte COLS = 4; //four columns

char keys[ROWS][COLS] =
{
  {'1', '2', '3', '4'},  //  the keyboard hardware is  a 3x4 grid...
  {'5', '6', '7', '8'},
  {'9', '0', 'A', 'B'},  // these values need  to be single char, so...
};
// The library will return the character inside this array when the appropriate
// button is pressed then look for that case statement. This is the key assignment lookup table.
// Layout(key/button order) looks like this
//     |----------------------------|
//     |                  [2/3]*    |     *TRS breakout connection. Keys 5 and 6 are duplicated at the TRS jack
//     |      [ 1] [ 2] [ 3] [ 4]   |     * Encoder A location = key[1]
//     |      [ 5] [ 6] [ 7] [ 8]   |     * Encoder B location = Key[4]
//     |      [ 9] [10] [11] [12]   |      NOTE: The mode button is not row/column key, it's directly wired to A0!!
//     |----------------------------|


byte rowPins[ROWS] = {4, 5, A3 };    //connect to the row pinouts of the keypad
byte colPins[COLS] = {6, 7, 8, 9 };  //connect to the column pinouts of the keypad

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

void setup()
{
  Serial.begin(9600);
  delay(200);

  Keyboard.begin();
}

void loop()
{
  char key = keypad.getKey();

  if (key == NO_KEY)
    return;

  //Serial.println(key);
  switch (key)
  {
    case '1': //macro example!!! Windows_Key+R = Run then type "mspaint" and press enter. Opens MS Paint
      Keyboard.press(KEY_LEFT_GUI);
      Keyboard.press('r'); 
      delay(150);
      Keyboard.release(KEY_LEFT_GUI);
      Keyboard.release('r');
      delay(150); //give your system time to catch up with these android-speed keyboard presses
      Keyboard.println("mspaint");
      break;

    case '2':
      Keyboard.press(KEY_LEFT_GUI);
      Keyboard.press(KEY_LEFT_ARROW); 
      delay(150);  //snaps window to left side of screen.
      break;

    case '3':
      Keyboard.press(KEY_LEFT_GUI);
      Keyboard.press(KEY_RIGHT_ARROW); 
      delay(150);  //snaps window to right side of screen.
      break;

    case '4':
      Keyboard.press(KEY_LEFT_ALT);
      Keyboard.press(KEY_F4); 
      delay(150);  //Closes active window
      break;

    case '5': //macro example: Windows_Key+R = Run then type "calc" and press enter. Opens MS Calculator
      Keyboard.press(KEY_LEFT_GUI);
      Keyboard.press('r'); 
      delay(150);
      Keyboard.release(KEY_LEFT_GUI);
      Keyboard.release('r');
      delay(150);                 //give your system time to catch up with these android-speed keyboard presses
      Keyboard.println("calc");
      break;

    case '6': //macro example: Windows_Key+R = Run then type "excel" and press enter. Opens MS Excel
      Keyboard.press(KEY_LEFT_GUI);
      Keyboard.press('r'); 
      delay(150);
      Keyboard.release(KEY_LEFT_GUI);
      Keyboard.release('r');
      delay(150);                 //give your system time to catch up with these android-speed keyboard presses
      Keyboard.println("excel");
      break;

    case '7': //macro example: Windows_Key+R = Run then type "winword" and press enter. Opens MS Word
      Keyboard.press(KEY_LEFT_GUI);
      Keyboard.press('r'); 
      delay(150);
      Keyboard.release(KEY_LEFT_GUI);
      Keyboard.release('r');
      delay(150);                 //give your system time to catch up with these android-speed keyboard presses
      Keyboard.println("winword");
      break;

    case '8': //macro that opens chrome and a random wiki page for learning.
      Keyboard.press(KEY_LEFT_GUI);
      Keyboard.press('r');
      Keyboard.release(KEY_LEFT_GUI);
      Keyboard.release('r');
      delay(50); //give your system time to catch up with these android-speed keyboard presses
      Keyboard.println("chrome"); 
      delay(500);
      Keyboard.println("https://en.wikipedia.org/wiki/Special:Random");
      break;

    case '9': //macro that opens Chrome & Rick Rolls you like a chump
      Keyboard.press(KEY_LEFT_GUI);
      Keyboard.press('r');
      Keyboard.release(KEY_LEFT_GUI);
      Keyboard.release('r');
      delay(50); //give your system time to catch up with these android-speed keyboard presses
      Keyboard.println("chrome"); 
      delay(500);
      Keyboard.println("https://www.youtube.com/watch?v=dQw4w9WgXcQ");
      break;

    case '0': //macro that opens Chrome and goes to my youtube channel!
      Keyboard.press(KEY_LEFT_GUI);
      Keyboard.press('r');
      Keyboard.release(KEY_LEFT_GUI);
      Keyboard.release('r');
      delay(50); //give your system time to catch up with these android-speed keyboard presses
      Keyboard.println("chrome"); 
      delay(500);
      Keyboard.println("https://www.youtube.com/c/ryanbatesrbg");
      break;

    case 'A': //minimize all windows (view desktop)
      Keyboard.press(KEY_LEFT_GUI);
      Keyboard.press('m');
      break;

    case 'B':
      Keyboard.press(KEY_LEFT_GUI);  //Opens Snip-it
      Keyboard.release(KEY_LEFT_GUI); 
      delay(25);
      Keyboard.println("snip");  //type "snip" and press "return"
      break;
  }
  delay(100); 
  Keyboard.releaseAll(); // this releases the buttons
}

Thank you. I wasn't sure what to remove. I'm learning how to do this stuff, but when I don't understand I get frustrated. I've been trying to figure it out for a few weeks now. I started this macro keyboard before I finished my cnc pen plotter, and as you know I had issues getting it going as well. Again thank you for the help.

Keep getting an error when I am compiling the code. The keyboard Library is installed and in the right location and it is saying the the Keyboard isn't found. Does you sketch contain '#include <Keyboard.h>'?

Did you select the Arduino Micro or Arduino Leonardo board first?

Please don't post pictures of cod and error messages

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

I did, but I will double check when I get home just to make sure.

I should have read the rules a little more.

I had the Arduino Pro or Pro Mini selected. I selectes the Arduino micro and it compiled but wouldn't up load. Then I tried the Leonardo and it compiled and uploaded. Now it works. I need to designate what key functions I want for autocad.

I have been trying to figure out how to use the mode button as a key command button. The guy that designed the board says it can e done. I haven't been able to figure it out yet.

The keyboard works great for what it's designed to do. I plan on building another one soon, but have two keypads instead of one.