0

I'm getting the error:

    left_hand:3:20: error: expected ']' before ';' token
     #define HAND_ROWS 5;
                        ^

on this code:

    #include <Keyboard.h>

    #define HAND_ROWS 5;
    #define HAND_COLS 6;
    #define ROW_PINS {9, 8, 7, 6, 5};
    #define COL_PINS {10, 16, 14, 15, 18, 19};
    #define LOOP_SPEED = 10;

    const char keymap[HAND_ROWS][HAND_COLS] = {{0xB1, '1', '2', '3', '4', '5'}, 
                                               {0xB3, 0x81, 'q', 'w', 'e', 'r'}, 
                                               {'6', 0x80, 'a', 's', 'd', 'f'}, 
                                               {'7', 'z', 'x', 'c', 'v', 'b'}, 
                                               {'h', 'j', 0x82, ' ', 'k', 'l'}};
    boolean pressedKeys;
    int keymapIndex;

help, please? This makes no sense to me... If I try to use Keyboard.LEFT_SHIFT and equivalent constants for the hex-codes in the keymap, they tell me 'expected unqualified-id before numerical constant' What does this even mean? I'm so lost...

1 Answers1

1

You mustn't terminate a #define with a ;. Semicolons are for C and C++ statements. #define is a preprocessor statement.

#define creates a literal string replacement, so when you use it you end up with:

const char keymap[5;][6;] = {...

which is, of course, wrong.

Majenko
  • 105,095
  • 5
  • 79
  • 137