Hello all, I am currently working on a macropad project for school. It is essentially a 2x3 arrangement of Cherry MX Switches that are connected to an Arduino Pro Micro that output letters, words, macros etc. when the switches are pressed. I am using the Keyboard library, with the keymap defined by a 2D matrix of the keys. Originally, I had problems uploading the code to the Arduino as it was giving me some errors named "butterfly" or something similar, I can't exactly remember. However, resetting the board whilst uploading the code had fixed it. The code has uploaded to the board with no errors, but pressing the switches does not work. Occasionally, random characters will be outputted that arent even in the code. Now whenever plugged in, all three red lights on the Arduino turn on. Resetting the board (connecting rst to grnd) does not do anything as the three red lights still turn on after a few seconds. I am very new to Arduino, so I'm not sure how to work around this problem. Also warning, I am very bad at soldering lol. I have provided the code and pictures of the wiring. Any help is super appreciated! Thanks.
#include <Keyboard.h>
const int numRows = 2;
const int numCols = 3;
const int rowPins[numRows] = {10, 16};
const int colPins[numCols] = {15, 18, 19};
// Define the keymap
char keys[numRows][numCols] = {
{'1', '2', '3'},
{'4', '5', '6'}
};
void setup() {
Keyboard.begin();
for (int i = 0; i < numRows; i++) {
pinMode(rowPins[i], INPUT_PULLUP);
}
for (int i = 0; i < numCols; i++) {
pinMode(colPins[i], OUTPUT);
digitalWrite(colPins[i], HIGH); // Add this line to set columns to HIGH initially
}
}
void loop() {
for (int col = 0; col < numCols; col++) {
digitalWrite(colPins[col], LOW);
for (int row = 0; row < numRows; row++) {
if (digitalRead(rowPins[row]) == LOW) {
Keyboard.write(keys[row][col]); // Use Keyboard.write to simplify keypress
delay(200); // Adjust for debounce
}
}
digitalWrite(colPins[col], HIGH);
}
}
First,,,read the instruction details at the beginning of the forum on how to post etc.
Second...supply a drawing ( no fritzing) of your complete ( including power supply) circuit.
Third.....details on how you uploaded code using what as programmer and how you did it.
Fourth.....use a simple code such as modified blink to ensure you are uploading correctly.
Did you intend to use "Keyboard.h" library for a six-button matrix? Your "keymap" looks more like a "Keypad"... but you would need to change your sketch where "keyboard" keywords are used.