Dear all,
For the last days I have been trying to hack an old typewriter keyboard matrix and simulate the key presses through arduino.
On the board of typewriter there are two rows of pins. One with 8 pins and one with 11. Whenever one of the 8 is connected to one of the 11 pins, one character is typed with this electromechanical part of the machine. I managed to connect each of these pins to map down each combination. I soldered jumper cables on the board and I connected them to the arduino.
First tested with just one character ( one pin from the one row and one from the other) and worked fine as a key press simulator. Then added more from the one row combining it with just one of the other row and after having some issues it worked.
Now whenever I add more wires from the second row(doesnt matter wich one is wich) it stops working and types nothing.
My project until now is pretty simular to this one, though im trying to controll the typewriter only with an arduino (not plus a rasberry). Any ideas what might be the problem and it stops working when im adding more pins to the arduino? I also tryied using diodes but didn't change anything.
Any ideas what might be the problem and it stops working when im adding more pins to the arduino or what I should change?
Im quite new this world of electronics so apologies for obvious mistakes.
Here is an AI code that partly worked on my project.
Thanks
#define NUM_ROWS 3
#define NUM_COLS 7
int rowPins[NUM_ROWS] = {A0, A1, A2}; // Row pins
int colPins[NUM_COLS] = {0, 1, 2, 3, 4, 5, 6}; // Column pins
char keyMap[NUM_ROWS][NUM_COLS] = {
{'Q', 'W', 'E', 'R', 'T', 'Y', 'U'}, // Row 1
{'A', 'S', 'D', 'F', 'G', 'H', 'J'}, // Row 2
{'Z', 'X', 'C', 'V', 'B', 'N', 'M'} // Row 3
};
void setup() {
Serial.begin(9600); // Start serial communication
// Initialize row pins as outputs
for (int i = 0; i < NUM_ROWS; i++) {
pinMode(rowPins[i], OUTPUT);
digitalWrite(rowPins[i], LOW); // Start with rows LOW
}
// Initialize column pins as inputs with pull-up resistors
for (int i = 0; i < NUM_COLS; i++) {
pinMode(colPins[i], INPUT_PULLUP); // Use internal pull-up resistors
}
}
void loop() {
for (int row = 0; row < NUM_ROWS; row++) {
digitalWrite(rowPins[row], HIGH); // Activate one row at a time
delay(10); // Small delay for stability
for (int col = 0; col < NUM_COLS; col++) {
if (digitalRead(colPins[col]) == HIGH) { // Key is pressed
Serial.print("Key Pressed: ");
Serial.println(keyMap[row][col]); // Print the key
delay(300); // Debounce delay to avoid multiple detections
}
delay(100); // Small delay after checking each column
}
digitalWrite(rowPins[row], LOW); // Deactivate row
delay(100); // Small delay after scanning each row
}
}
`