Normalmente se hacen teclados o macropads con Arduino Micro Pro. Sin embargo, puede que no tengas a tu disposición uno de estos o te hayas equivocado al comprar (como yo). El arduino nano no tiene HID, es decir que la PC no lo puede recnocer como teclado.
En arduino, cada vez que presionemos una tecla enviará un carácter a través de Serial.
Con python debemos capturar qué carácter fue y que acción de teclado se ejecutará.
Esto para cada tecla del Keypad.
Hardware:
- Cable.
- Diodos (1N4148). (uno por switch).
- Switches.
- Keycaps.
- Arduino Nano
- Case y Plate
- Tornillos M3x16mm.
A través del administrador de librerías de Arduino debemos instalar Keypad de los autores Mark Stanley y Alexander Brevig.
En ./arduino hay dos códigos, uno para un keypad de 3x3 y otro para 4x4, tomando esos códigos como ejemplo podrías modificarlos para hacer de otra matriz.
Después de instalar python, es necesario instalar unas dependencias para que funcione el código.
Windows: Ejecutar Power Shell / CMD como administrador
python -m pip install --upgrade pip
Esta librería nos ayudará con la comunicación entre el arduino y python a través del puerto serial.
python -m pip install pyserial
Con pyautogui seremos capaces de "presionar" teclas a través de código.
python -m pip install pyautogui
En macro_key_pad_XxX.pyw modificar el COMx, podes ver qué numero va en ArduinoIDE.
También podés modificar qué hace cada tecla en macro_key_pad_xXx.pyw, toda la documentación está en su página.
Correr macro_key_pad_xXx.pyw.
Generalmente estos teclados suelen tener pines que representan las filas y las columnas de la matriz de pulsadores. Conectarás cada pin del teclado a un pin digital del arduino. Se haría lo mismo pero con dos pines menos en una matriz de 3x3.
Podés usar el case que quieras, te dejo dos cases que funcionan con arduino nano.
./case/XxX/nano_xxx
- Hicimos uno de 3x3 y uno de 4x4, cada uno tiene un case inclinado 5 grados y otro recto.
- Estan hechos para tornillos M3x16mm.
Si se quiere modificar algo, está el archivo de Fusion 360 en
./case/XxX/macropad_XxX.f3d
.
Hecho por: Mante#7952 (discord).
Keyboards or macropads are usually made with Arduino Pro Micro. However, you may not have one of these at your disposal or you may have made a mistake when buying (like me). The arduino nano does not have HID, meaning that the PC cannot recognize it as a keyboard.
In arduino, every time we press a key it will send a character through Serial.
With python we must capture what character it was and what keyboard action will be executed.
This for each key on the Keypad.
Hardware:
- Cable.
- Diodes (1N4148). (one per switch).
- Switches.
- Keycaps.
- Arduino Pro Micro USB C
- Case and Plate
- M3x16mm screws.
Through the Arduino library manager we must install Keypad by authors Mark Stanley and Alexander Brevig.
In ./arduino there are two codes, one for a 3x3 keypad and one for 4x4, taking those codes as an example you could modify them to make another matrix.
After installing python, you need to install some dependencies for the code to work.
Windows: Run Power Shell / CMD as administrator
python -m pip install --upgrade pip
This library will help us with the communication between the arduino and python through the serial port.
python -m pip install pyserial
With pyautogui we will be able to "press" keys through code.
python -m pip install pyautogui
In macro_key_pad_xXx.pyw modify the COMx, you can see which number goes in ArduinoIDE.
You can also modify what each key does in MacroKeyPadxXx.pyw, all the documentation is in its page.
Run macro_key_pad_xXx.pyw.
Generally these keyboards usually have pins that represent the rows and columns of the pushbutton matrix. You will connect each pin on the keypad to a digital pin on the arduino. You would do the same but with two less pins in a 3x3 matrix.
You can use any case you want, here are two cases that work with arduino nano.
- case/XxX`.
- We made a 3x3 and a 4x4, each one has a case inclined 5 degrees and another one straight.
If you want to modify something, there is the Fusion 360 file in ./case/XxX/macropad_XxX.f3d
.
Código principal: @crixodia, código.
Video relacionado: @Hazz Techno Dance, Video.
Macropad: void16.