Arduino Macro is a tool to use a Arduino Leonardo or Arduino ESP32 as a macro keyboard. It is based on the Arduino Keyboard library and ESP32-BLE-Keyboard library. Depending on the board you use, you can use the Arduino Leonardo as a USB keyboard or the ESP32 as a Bluetooth keyboard.
- Install the Arduino IDE
- Add the libraries:
- For the Arduino Leonardo: Go to
Sketch > Include Library > Manage Libraries...
and search forKeyboard
and install it. - For the ESP32: Follow the instructions on the ESP32-BLE-Keyboard repository.
- For the Arduino Leonardo: Go to
- Install python3 with the following packages:
pip install pyserial pip install numpy
- Connect the Arduino to your computer.
- Open the
com.txt
file and write the COM port of your Arduino. (e.g.COM3
, you can find the COM port in the Arduino IDE underTools > Port
) - Open the
map_buttons
folder and flash themap_buttons.ino
file to your Arduino. - Run the
map_buttons.py
file to map the buttons of your Arduino and follow the instructions.(note: firstpython map_buttons.py
button
will be thereset key
and the lastbutton
will be theenter key
) - Flash the
arduino_macro.ino
file to your Arduino. - Open the
terminal
folder and run theinit_terminal.py
file to initialize the terminal.python init_terminal.py
- Run the
terminal.py
file to use communication with the Arduino. (note: the arduino can change the COM port, so you may need to modify thecom.txt
file)python terminal.py
- Once the terminal is open, you can send the commands
help
to see the available commands. - Once the Arduino setup as you want, you no longer need to run the
terminal.py
file, you can use the Arduino as a macro keyboard.
The arduino_macro
scetch is the main scetch to use the Arduino as a macro keyboard.
It can be programmed with the terminal.py
or any other serial communication tool.
By default, the buttons
are mapped to the corresponding memories
(e.g. button 0
is mapped to memory 0
).
This mapping can be changed in the setup.h
file by changing the map_buttons
array.
To unlock the device you can set press the reset key
and then press the password
(default 0
) and then press the enter key
to validate the password.
You can change the password
with the key
command.
(note: the password
is a succession of number between 1
and nb_buttons-1
as the reset key
and the enter key
are reserved)
help
: Show the available commands.echo <data>
: Write the data and send it back.write <data>
: Write the data.send <data>
: Send the data.keycode [<name>]
: Get the keycode of the key.locked
: Check if the device is locked.len
: Get the number of data space.save <index> <data>
: Save the data at index.load <index>
: Load the data at index.clear [<index>]
: Clear the data (default all).unlock <key>
: Unlock the device (default 0).lock
: Lock the device.key [<key>]
: Get/set the key to unlock.info
: Get the information.