A 6-key mechanical macropad powered by an Arduino Pro Micro, featuring an OLED display, haptic feedback, and multiple, easily swappable macro layers.
This project is built with a focus on modular, readable, and easily customizable code.
- 6 Programmable Keys: Five keys for macros and one dedicated key to cycle through menus.
- OLED Status Display: A 128x32 SSD1306 OLED screen shows the currently active macro menu (e.g., "Common", "Coding").
- Haptic Feedback: A small vibration motor provides physical confirmation on key presses and menu changes.
- Multiple Macro Layers: Switch between different sets of macros on-the-fly. The code includes pre-configured layers for common shortcuts and coding tasks.
- Modular C++ Code: The logic is encapsulated in a
MechMacroclass, making it easy to understand, maintain, and extend. - Cross-Platform Support: Macro definitions include key mappings for both Windows and macOS.
- Arduino Pro Micro (or a compatible ATmega32U4-based board)
- 1x SSD1306 I2C OLED Display (128x32)
- 6x Mechanical Keyboard Switches
- 1x Small Vibration Motor (e.g., pancake or cylindrical)
- Resistors to create a resistor ladder for analog button input.
- Wires, a breadboard, or a custom PCB.
Install the libraries using the Arduino IDE's Library Manager.
- Clone the repository:
git clone https://github.com/AtaCanYmc/MechKeyPad
- Hardware Assembly: Connect the components to the Arduino Pro Micro as defined in the code:
- OLED Display: Connect via I2C (VCC, GND, SCL, SDA).
- Buttons: Wire the 6 buttons using a resistor ladder, with the output connected to pin
A0. - Vibration Motor: Connect to pin
5(orHAPTIC_FEEDBACK_PIN).
- Configure: Open
MechKeyPad.ino. At the top, select your target operating system:// Change to MAC if you are on macOS MechMacro macroPad(WINDOWS);
- Upload: Select "Arduino Leonardo" or "SparkFun Pro Micro" from the board menu in the Arduino IDE and upload the sketch.
- Press Buttons 1-5: Trigger the corresponding macro for the currently active menu.
- Press Button 6: Cycle through the available menus (e.g., "Clicker" -> "Common" -> "Coding").
- The OLED display will update to show the name of the current menu.
Customizing macros is straightforward:
- Open the
MechMacro.cppfile. - Locate the
COMMON_MACROSandCODING_MACROSarrays. - Modify the existing entries or add new ones. Each macro has a name, a set of Windows keys, and a set of macOS keys.
// Example macro definition:
// {"Name", {WIN_KEY_1, WIN_KEY_2, 0}, {MAC_KEY_1, MAC_KEY_2, 0}}
{"Copy", {KEY_LEFT_CTRL, 'c', 0}, {KEY_LEFT_GUI, 'c', 0}},If your button readings are inconsistent, you may need to calibrate the analog value ranges in the getButtonIndex() function inside MechMacro.cpp. Use the Arduino Serial Monitor to see the values your hardware produces for each key press.
