I made a small piece of code in Arduino to test out my 3x3 keyboard pad (below). Right now I have it programmed to returned 1-9 depending on the key pressed.
What I would like it to do though is to have different keys for different programs. For example in a game, the 9 keys could correspond to 1-9, while in a different program it could be directional arrows and some other keys.
I would like to be able to controller this on an software level, so the teensy doesn't need to be flashed every time. I'm not sure how to proceed with that though. Any thoughts?
Thanks
What I would like it to do though is to have different keys for different programs. For example in a game, the 9 keys could correspond to 1-9, while in a different program it could be directional arrows and some other keys.
I would like to be able to controller this on an software level, so the teensy doesn't need to be flashed every time. I'm not sure how to proceed with that though. Any thoughts?
Thanks
Code:
#include <Bounce.h>
Bounce button0 = Bounce(0, 10);
Bounce button1 = Bounce(1, 10);
Bounce button2 = Bounce(2, 10);
Bounce button3 = Bounce(3, 10);
Bounce button4 = Bounce(6, 10);
Bounce button5 = Bounce(4, 10);
Bounce button6 = Bounce(13, 10);
Bounce button7 = Bounce(14, 10);
Bounce button8 = Bounce(15, 10);
void setup()
{
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(13, INPUT_PULLUP);
pinMode(14, INPUT_PULLUP);
pinMode(15, INPUT_PULLUP);
}
void loop()
{
button0.update();
button1.update();
button2.update();
button3.update();
button4.update();
button5.update();
button6.update();
button7.update();
button8.update();
if (button0.fallingEdge()){
Keyboard.print("1");
}
if (button1.fallingEdge()){
Keyboard.print("2");
}
if (button2.fallingEdge()){
Keyboard.print("3");
}
if (button3.fallingEdge()){
Keyboard.print("4");
}
if (button4.fallingEdge()){
Keyboard.print("5");
}
if (button5.fallingEdge()){
Keyboard.print("6");
}
if (button6.fallingEdge()){
Keyboard.print("7");
}
if (button7.fallingEdge()){
Keyboard.print("8");
}
if (button8.fallingEdge()){
Keyboard.print("9");
}
}