I've read that the USB keyboard method only sends 6 keys at a time. I'm looking for methods others have used to coordinate the use of 7 or more keys. In my example code, you'll see the obvious error where it assumes it can update the keystate of 12 keys at a time. If I can better understand how it's limited to 6, I can write some code to evaluate the keys first, then send the keystate updates in groups.
p.s.: will this run too fast? do I need a delay?
#include <Bounce.h>
Bounce button01 = Bounce(1, 10);
Bounce button02 = Bounce(2, 10);
Bounce button03 = Bounce(3, 10);
Bounce button04 = Bounce(4, 10);
Bounce button05 = Bounce(5, 10);
Bounce button06 = Bounce(6, 10);
Bounce button07 = Bounce(7, 10);
Bounce button08 = Bounce(8, 10);
Bounce button09 = Bounce(9, 10);
Bounce button10 = Bounce(10, 10);
Bounce button11 = Bounce(11, 10);
Bounce button12 = Bounce(12, 10);
void setup() {
pinMode(1, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(8, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(11, INPUT_PULLUP);
pinMode(12, INPUT_PULLUP);
}
void loop() {
// Update all the buttons.
button01.update();
button02.update();
button03.update();
button04.update();
button05.update();
button06.update();
button07.update();
button08.update();
button09.update();
button10.update();
button11.update();
button12.update();
// Check each button for "falling" edge.
if (button01.fallingEdge()) {
Keyboard.set_key1(KEY_F13);
}
if (button02.fallingEdge()) {
Keyboard.set_key2(KEY_F14);
}
if (button03.fallingEdge()) {
Keyboard.set_key3(KEY_F15);
}
if (button04.fallingEdge()) {
Keyboard.set_key4(KEY_F16);
}
if (button05.fallingEdge()) {
Keyboard.set_key5(KEY_F17);
}
if (button06.fallingEdge()) {
Keyboard.set_key6(KEY_F18);
}
if (button07.fallingEdge()) {
Keyboard.set_key7(KEY_F19);
}
if (button08.fallingEdge()) {
Keyboard.set_key8(KEY_F20);
}
if (button09.fallingEdge()) {
Keyboard.set_key9(KEY_F21);
}
if (button10.fallingEdge()) {
Keyboard.set_key10(KEY_F22);
}
if (button11.fallingEdge()) {
Keyboard.set_key11(KEY_F23);
}
if (button12.fallingEdge()) {
Keyboard.set_key12(KEY_F24);
}
// Check each button for "rising" edge
if (button01.risingEdge()) {
Keyboard.set_key1(0);
}
if (button02.risingEdge()) {
Keyboard.set_key2(0);
}
if (button03.risingEdge()) {
Keyboard.set_key3(0);
}
if (button04.risingEdge()) {
Keyboard.set_key4(0);
}
if (button05.risingEdge()) {
Keyboard.set_key5(0);
}
if (button06.risingEdge()) {
Keyboard.set_key6(0);
}
if (button07.risingEdge()) {
Keyboard.set_key7(0);
}
if (button08.risingEdge()) {
Keyboard.set_key8(0);
}
if (button09.risingEdge()) {
Keyboard.set_key9(0);
}
if (button10.risingEdge()) {
Keyboard.set_key10(0);
}
if (button11.risingEdge()) {
Keyboard.set_key11(0);
}
if (button12.risingEdge()) {
Keyboard.set_key12(0);
}
Keyboard.send_now();
}