Created
March 9, 2023 09:51
-
-
Save peeranatkankham/39d152d7332c081fc88ef74300db75ca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Button2.h" | |
#include <BleKeyboard.h> | |
BleKeyboard bleKeyboard; | |
#define BUTTON_A_PIN 16 | |
#define BUTTON_B_PIN 17 | |
#define BUTTON_C_PIN 5 | |
#define BUTTON_D_PIN 18 | |
#define BUTTON_E_PIN 23 | |
#define BUTTON_F_PIN 19 | |
#define BUTTON_G_PIN 12 | |
#define BUTTON_H_PIN 14 | |
#define BUTTON_I_PIN 27 | |
#define BUTTON_J_PIN 26 | |
#define BUTTON_K_PIN 25 | |
#define BUTTON_L_PIN 33 | |
Button2 buttonA, buttonB, buttonC, buttonD, buttonE, buttonF, buttonG, buttonH, buttonI, buttonJ, buttonK, buttonL; | |
void setup() { | |
buttonA.begin(BUTTON_A_PIN); | |
buttonA.setClickHandler(click); | |
buttonB.begin(BUTTON_B_PIN); | |
buttonB.setClickHandler(click); | |
buttonC.begin(BUTTON_C_PIN); | |
buttonC.setClickHandler(click); | |
buttonD.begin(BUTTON_D_PIN); | |
buttonD.setClickHandler(click); | |
buttonE.begin(BUTTON_E_PIN); | |
buttonE.setClickHandler(click); | |
buttonF.begin(BUTTON_F_PIN); | |
buttonF.setClickHandler(click); | |
buttonG.begin(BUTTON_G_PIN); | |
buttonG.setClickHandler(click); | |
buttonH.begin(BUTTON_H_PIN); | |
buttonH.setClickHandler(click); | |
buttonI.begin(BUTTON_I_PIN); | |
buttonI.setClickHandler(click); | |
buttonJ.begin(BUTTON_J_PIN); | |
buttonJ.setClickHandler(click); | |
buttonK.begin(BUTTON_K_PIN); | |
buttonK.setClickHandler(click); | |
buttonL.begin(BUTTON_L_PIN); | |
buttonL.setClickHandler(click); | |
bleKeyboard.begin(); | |
} | |
void loop() { | |
buttonA.loop(); | |
buttonB.loop(); | |
buttonC.loop(); | |
buttonD.loop(); | |
buttonE.loop(); | |
buttonF.loop(); | |
buttonG.loop(); | |
buttonH.loop(); | |
buttonI.loop(); | |
buttonJ.loop(); | |
buttonK.loop(); | |
buttonL.loop(); | |
} | |
void click(Button2& btn) { | |
if (btn == buttonA) { | |
bleKeyboard.press(KEY_LEFT_CTRL); | |
bleKeyboard.press(KEY_LEFT_ALT); | |
bleKeyboard.press('n'); | |
delay(100); | |
bleKeyboard.releaseAll(); | |
Serial.println("A clicked"); | |
} else if (btn == buttonB) { | |
bleKeyboard.press(KEY_LEFT_CTRL); | |
bleKeyboard.press(KEY_LEFT_ALT); | |
bleKeyboard.press('t'); | |
delay(100); | |
bleKeyboard.releaseAll(); | |
}else if (btn == buttonC) { | |
bleKeyboard.press(KEY_LEFT_ALT); | |
bleKeyboard.press('a'); | |
delay(100); | |
bleKeyboard.releaseAll(); | |
}else if (btn == buttonD) { | |
bleKeyboard.write(KEY_MEDIA_PREVIOUS_TRACK); | |
}else if (btn == buttonE) { | |
bleKeyboard.write(KEY_MEDIA_NEXT_TRACK); | |
}else if (btn == buttonF) { | |
bleKeyboard.write(KEY_MEDIA_PLAY_PAUSE); | |
}else if (btn == buttonG) { | |
bleKeyboard.press(KEY_LEFT_SHIFT); | |
bleKeyboard.press(KEY_DELETE); | |
delay(100); | |
bleKeyboard.releaseAll(); | |
}else if (btn == buttonH) { | |
bleKeyboard.press(KEY_LEFT_CTRL); | |
bleKeyboard.press(KEY_LEFT_SHIFT); | |
bleKeyboard.press('i'); | |
delay(100); | |
bleKeyboard.releaseAll(); | |
}else if (btn == buttonI) { | |
bleKeyboard.press(KEY_LEFT_CTRL); | |
bleKeyboard.press('/'); | |
delay(100); | |
bleKeyboard.releaseAll(); | |
}else if (btn == buttonJ) { | |
bleKeyboard.press(KEY_LEFT_CTRL); | |
bleKeyboard.press(KEY_LEFT_SHIFT); | |
bleKeyboard.press(KEY_ESC); | |
delay(100); | |
bleKeyboard.releaseAll(); | |
}else if (btn == buttonK) { | |
bleKeyboard.write(KEY_MEDIA_CALCULATOR); | |
}else if (btn == buttonL) { | |
bleKeyboard.write(KEY_MEDIA_LOCAL_MACHINE_BROWSER); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment