#include "Keyboard.h"
//declaring button pins (this is where you solder your momentary switches to - other side of switch goes to ground)
const int buttonPinA = 2;
const int buttonPinA = 3;
const int buttonPinA = 4;
int previousButtonStateA = HIGH;
int previousButtonStateB = HIGH;
int previousButtonStateC = HIGH;
void setup() {
//declare the buttons as input_pullup
pinMode(buttonPinA, INPUT_PULLUP);
pinMode(buttonPinB, INPUT_PULLUP);
pinMode(buttonPinC, INPUT_PULLUP);
Keyboard.begin();
}
void loop() {
//checking the state of the button
int buttonStateA = digitalRead(buttonPinA);
int buttonStateB = digitalRead(buttonPinB);
int buttonStateC = digitalRead(buttonPinC);
////////// button A
if (buttonStateA == LOW && previousButtonStateA == HIGH) {
// and it's currently pressed:
Keyboard.press(32); // ASCII character for space
delay(50);
}
if (buttonStateA == HIGH && previousButtonStateA == LOW) {
// and it's currently released:
Keyboard.release(32); // ASCII character for space
delay(50);
}
////////// button B
if (buttonStateB == LOW && previousButtonStateB == HIGH) {
// and it's currently pressed:
Keyboard.press(97); // ASCII character for a
delay(50);
}
if (buttonStateB == HIGH && previousButtonStateB == LOW) {
// and it's currently released:
Keyboard.release(97); // ASCII character for a
delay(50);
}
////////// button C
if (buttonStateC == LOW && previousButtonStateC == HIGH) {
// and it's currently pressed:
Keyboard.press(98); // ASCII character for b
delay(50);
}
if (buttonStateC == HIGH && previousButtonStateC == LOW) {
// and it's currently released:
Keyboard.release(98); // ASCII character for b
delay(50);
}
///////////////
previousButtonStateA = buttonStateA;
previousButtonStateB = buttonStateB;
previousButtonStateC = buttonStateC;
}
This should be the easiest for you to read. This will give you three buttons.
When you plug the arduino on over USB, it will identify as a keyboard. Then the three buttons you click are just like pressing a key on a standard keyboard- output being through that USB connection. I'd probably use something like an ethernet cable with ethercons on the end to connect the unlatched switch box to the box housing the arduino.
If you can solder, you can do this.