Difference between revisions of "Macro Keypad"
| Ben Norcutt (talk | contribs) | Ben Norcutt (talk | contribs)  | ||
| Line 20: | Line 20: | ||
| Uses the blekeyboard library for Arduino from ----- | Uses the blekeyboard library for Arduino from ----- | ||
| + | |||
| + | <nowiki>#define UK_KEYBOARD 1 | ||
| + | |||
| + | #include <Arduino.h> | ||
| + | #include <BleKeyboard.h> | ||
| + | BleKeyboard bleKeyboard; | ||
| + | |||
| + | |||
| + | // Change the below values if desired | ||
| + | #define BUTTON_1_PIN 23 | ||
| + | #define BUTTON_2_PIN 22 | ||
| + | #define MESSAGE "Hello from ESP32\n" | ||
| + | #define DEVICE_NAME "My Keyboard" | ||
| + | |||
| + | |||
| + | // Forward declarations | ||
| + | void bluetoothTask(void*); | ||
| + | void typeText(const char* text); | ||
| + | |||
| + | |||
| + | bool isBleConnected = false; | ||
| + | |||
| + | |||
| + | void setup() { | ||
| + |     Serial.begin(115200); | ||
| + |     bleKeyboard.begin(); | ||
| + |     // configure pin for button | ||
| + |     pinMode(BUTTON_1_PIN, INPUT_PULLUP); | ||
| + |     pinMode(BUTTON_2_PIN, INPUT_PULLUP); | ||
| + | } | ||
| + | |||
| + | |||
| + | void loop() {   | ||
| + |     if (bleKeyboard.isConnected() && digitalRead(BUTTON_1_PIN) == LOW) { | ||
| + |         // button has been pressed: type message | ||
| + |         //Serial.println(MESSAGE); | ||
| + |         //typeText(MESSAGE); | ||
| + |         Serial.println("Sending Ctrl+Alt+Shift..."); | ||
| + |         bleKeyboard.press(KEY_LEFT_CTRL); | ||
| + |         bleKeyboard.press(KEY_LEFT_ALT); | ||
| + |         bleKeyboard.press(KEY_LEFT_SHIFT); | ||
| + |         delay(100); | ||
| + |         bleKeyboard.releaseAll(); | ||
| + |         Serial.println("Sending F3..."); | ||
| + |         //bleKeyboard.press(KEY_F3); | ||
| + |         bleKeyboard.press(KEY_LEFT_ALT); | ||
| + |         bleKeyboard.press('a'); | ||
| + |         delay(100); | ||
| + |         bleKeyboard.releaseAll();        | ||
| + |              } | ||
| + | if (bleKeyboard.isConnected() && digitalRead(BUTTON_2_PIN) == LOW) { | ||
| + |         // button has been pressed: type message | ||
| + |         //Serial.println(MESSAGE); | ||
| + |         //typeText(MESSAGE); | ||
| + |         Serial.println("Sending Ctrl+Alt+Shift..."); | ||
| + |         bleKeyboard.press(KEY_LEFT_CTRL); | ||
| + |         bleKeyboard.press(KEY_LEFT_ALT); | ||
| + |         bleKeyboard.press(KEY_LEFT_SHIFT); | ||
| + |         delay(100); | ||
| + |         bleKeyboard.releaseAll(); | ||
| + |         Serial.println("Sending F3..."); | ||
| + |         //bleKeyboard.press(KEY_F3); | ||
| + |         bleKeyboard.press(KEY_LEFT_ALT); | ||
| + |         bleKeyboard.press('v'); | ||
| + |         delay(100); | ||
| + |         bleKeyboard.releaseAll();        | ||
| + |              } | ||
| + | } | ||
| + | |||
| + | </nowiki> | ||
Revision as of 15:43, 16 March 2021
What is it?
A macro keypad is physical or touch screen keypad that maps multiple or common used shortcut keys to an individual action, think (un)mute on Zoom which by default is ALT + A
Prior Art
Implementation
There are multiple ways this can be done and a common approach is to use a Pro Micro as it has the ability to be programmed as a HID device and emulate both keyboard and mouse however I struggled to do this so ended using an ESP32 and presenting it as a bluetooth keyboard.
V1.00 - Status abandoned couldn't get Pro Micro to program
Pro micro - generic clone
3D Printed case - link from thingiverse goes here
Cherry MX clone switches - ebay link here
V1.01 - Status working ESP32-WROOM Module 3D Printed case - link from thingiverse goes here Cherry MX clone switches - ebay link here
Currently have 2 switched hooked up to ESP32 sending ALT + a to mute and unmute and ALT + v to start and stop video
Uses the blekeyboard library for Arduino from -----
#define UK_KEYBOARD 1 #include <Arduino.h> #include <BleKeyboard.h> BleKeyboard bleKeyboard; // Change the below values if desired #define BUTTON_1_PIN 23 #define BUTTON_2_PIN 22 #define MESSAGE "Hello from ESP32\n" #define DEVICE_NAME "My Keyboard" // Forward declarations void bluetoothTask(void*); void typeText(const char* text); bool isBleConnected = false; void setup() { Serial.begin(115200); bleKeyboard.begin(); // configure pin for button pinMode(BUTTON_1_PIN, INPUT_PULLUP); pinMode(BUTTON_2_PIN, INPUT_PULLUP); } void loop() { if (bleKeyboard.isConnected() && digitalRead(BUTTON_1_PIN) == LOW) { // button has been pressed: type message //Serial.println(MESSAGE); //typeText(MESSAGE); Serial.println("Sending Ctrl+Alt+Shift..."); bleKeyboard.press(KEY_LEFT_CTRL); bleKeyboard.press(KEY_LEFT_ALT); bleKeyboard.press(KEY_LEFT_SHIFT); delay(100); bleKeyboard.releaseAll(); Serial.println("Sending F3..."); //bleKeyboard.press(KEY_F3); bleKeyboard.press(KEY_LEFT_ALT); bleKeyboard.press('a'); delay(100); bleKeyboard.releaseAll(); } if (bleKeyboard.isConnected() && digitalRead(BUTTON_2_PIN) == LOW) { // button has been pressed: type message //Serial.println(MESSAGE); //typeText(MESSAGE); Serial.println("Sending Ctrl+Alt+Shift..."); bleKeyboard.press(KEY_LEFT_CTRL); bleKeyboard.press(KEY_LEFT_ALT); bleKeyboard.press(KEY_LEFT_SHIFT); delay(100); bleKeyboard.releaseAll(); Serial.println("Sending F3..."); //bleKeyboard.press(KEY_F3); bleKeyboard.press(KEY_LEFT_ALT); bleKeyboard.press('v'); delay(100); bleKeyboard.releaseAll(); } }
