i am new to this aurdino. Herewith my code is attached its 5x4 matrix push button box for usb console, we can connected row and column pins for 20 buttons . But all i want is LED on when i press a single button EX: {0,1,2,3} -When i press 3 i want LED on off and its 3 pin ON-OFF toggle switch ,kindly help me sorry for my english.Thanks
BOARD-LEONARDO
#include <Joystick.h>
#include <Keypad.h>
#define ENABLE_PULLUPS
#define NUMBUTTONS 20
#define NUMROWS 5
#define NUMCOLS 4
const int ROW_NUM = 5; //four rows
const int COLUMN_NUM = 4; //three columns
char keys[ROW_NUM][COLUMN_NUM] = {
{0,1,2,3},
{4,5,6,7},
{8,9,10,11},
{12,13,14,15},
{16,17,18,19}
};
byte pin_rows[ROW_NUM] = {10, 9, 8, 7,6}; //connect to the row pinouts of the keypad
byte pin_column[COLUMN_NUM] = {5, 4, 3,2}; //connect to the column pinouts of the keypad
Keypad buttbx = Keypad( makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM );
Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,
JOYSTICK_TYPE_JOYSTICK, 20, 0,
false, false, false, false, false, false,
false, false, false, false, false);
void setup() {
Joystick.begin();
}
void loop() {
CheckAllButtons();
}
void CheckAllButtons(void) {
if (buttbx.getKeys())
{
for (int i=0; i<LIST_MAX; i++)
{
if ( buttbx.key[i].stateChanged )
{
switch (buttbx.key[i].kstate) {
case PRESSED:
case HOLD:
Joystick.setButton(buttbx.key[i].kchar, 1);
break;
case RELEASED:
case IDLE:
Joystick.setButton(buttbx.key[i].kchar, 0);
break;
}
}
}
}
}