Hello guys,
as I was currently adding a 4x4 keypad to my very first sequencer,
I got myself into some trouble with keypad buttons and the way to debounce them efficiently.
The code I am trying to use is this one, where the indexes of "button" match indexes of "played" :
for (short i=0;i<4;i++){
for (short j = 0;j<4;j++){
if (button[i][j].update()){ // error in request for member "update";
if (played[i][j]== 1) //the array "played" records sequences which have to be played.
played[i][j] = 0;
else
played[i][j] = 1;
}
}
}
And this is the way I tried to create it.
There are several problems which are:
It seems I can't use indexes when creating Bounce objects, because gcc tells me they could be uninitialized.
I need to create the Bounce objects outside of the setup function but it seems that this isn't legit to use incrementation there.
char button[4][4] = {
{'0','1','2','3'},
{'4','5','6','7'},
{'8','9','A','B'},
{'C','D','E','F'}
};
for (short i=0; i<4; i++){
for (short j=0; j<4; j++){
Bounce button[i][j] = Bounce();
button[i][j].attach(array[i][j]); //array is filled with input pins
button.interval(5);
}
}
I saw there was a keypad library but this isn't that much useful if I got it right,
because I would have to write something like this:
pressed = Keypad.getKey();
if (pressed == '0')
played[0][0] = 1;
if (pressed == '1')
played[0][1] = 1;
//etc...
So, I am pretty stucked and don't know how to go where I want,
any help guys ?
Thank you !