#include #include #include long oldPosition = -999; //Encoder pin A and B to pin 0 and 1 Encoder rEnc(0, 1); #define ENABLE_PULLUPS #define NUMBUTTONS 16 #define NUMROWS 4 #define NUMCOLS 4 byte buttons[NUMROWS][NUMCOLS] = { {0,1,2,3}, {4,5,6,7}, {8,9,10,11}, {12,13,14,15}, }; byte rowPins[NUMROWS] = {12, 13, 18, 19}; //connect to the row pinouts of the keypad byte colPins[NUMCOLS] = {20, 21, 22, 23}; //connect to the column pinouts of the keypad Keypad buttbx = Keypad( makeKeymap(buttons), rowPins, colPins, NUMROWS, NUMCOLS); Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,JOYSTICK_TYPE_MULTI_AXIS, 16, 0, // Button Count, Hat Switch Count true, true, true, // X and Y, Z Axis false, false, false, // Rx, Ry, Rz false, false, // Rudder, Throttle false, false, false); // Accelerator, Brake, Steering void setup() { Joystick.begin(); Joystick.setXAxisRange(-32767, 32767); Joystick.setYAxisRange(-32767, 32767); Joystick.setZAxisRange(-32767, 32767); // Serial.begin(9600); } void loop() { CheckAllButtons(); CheckAllEncoders(); } void CheckAllButtons(void) { if (buttbx.getKeys()) { for (int i=0; i