Ich will für meine Simulator eine 6x6 Matrix mit schalter und knopfen haben. Das grundlegende vom programm mit debounce und schalter habe ich alles. Ich weiß nur nicht wie ich die 36 signale an den pc leite. das bis jetzt alle tastatur tasten belegt sind müssen die signal als gamepad mit 36 button gesendet werden. Die libs die ich bis jetzt gefunden hatte, hatten nur bis 32. und HID-Project habe ich noch nicht verstanden
Der Code den ich jetzt habe scan die matrix und sendet es über serial. Die HID Commands habe ich nutzlos gemacht
//#include <HID-Project.h>
const int colPins[] = {2, 3, 4, 5, 6, 7};
const int rowPins[] = {8, 9, 10, 14, 15, 16};
const int numRows = 6;
const int numCols = 6;
uint8_t rawhidData[255];
bool isSwitchButton[numRows][numCols] = {
{true, true, true, true, true, true},
{true, true, true, true, true, true},
{true, true, true, true, true, true},
{true, true, true, true, true, true},
{true, true, true, true, true, true},
{true, true, true, true, true, true}
};
bool butonstate[numRows][numCols] = {0};
void setup() {
for (int col = 0; col < numCols; col++) {
pinMode(colPins[col], INPUT_PULLUP);
}
for (int row = 0; row < numRows; row++) {
pinMode(rowPins[row], OUTPUT);
digitalWrite(rowPins[row], HIGH);
}
Serial.begin(115200);
// RawHID.begin(rawhidData, sizeof(rawhidData));
}
void loop() {
bool SEND[36] = {0};
byte i = 0;
for (int col = 0; col < numCols; col++) {
digitalWrite(rowPins[col], LOW);
for (int row = 0; row < numRows; row++) {
butonstate[row][col] = !digitalRead(colPins[row]);
i = (row+1) + (col*6);
SEND[i] = !digitalRead(colPins[row]);
}
digitalWrite(rowPins[col], HIGH);
}
for (int l = 1; l < 37; l++){
Serial.print(SEND[l]);
}
Serial.println(" ");
delay(100);
}
In meinem aktuellen Test Aufbau sind alles schalter
