# Typewriter keyboard matrix control with Arduino

I have an electric typewriter that I bought at a yard sale, and am trying to turn into a teletype-esque machine using an Arduino. I already asked this once before, but I've gotten a lot further into figuring out how this thing works. as @PeterJ guessed, it was a matrix, with different keypresses connecting 2 pins.

My question: Knowing which pins were connected by each key, how would I connect the Arduino to the pins to simulate keypresses? There are pictures on my previous question, and I'll put them here if that's needed.

It is likely that the matrix is driven with 5 volt signals. If so, you could connect the scanning signal lines (rows or cols depending on the typewriter) tp input pins on the Arduino. You'd also connect the feedback lines (row or cols- the opposite of which was used for the scanning) to output lines on the Arduino.

Finally, you'd write a sketch that watched the incoming scan lines and would light up the corresponding feedback line whenever it wanted to type a character.

Make sense?

• It is likely that the matrix is driven with 5 volt signals. Citation Required. – Passerby Nov 24 '15 at 21:47
• It was the 80's and I see TTL logic on the board, so likely but certainly not certain. I'd test first if possible. Scope would be easiest, but a capacitor+diode+multimeter peak voltage detector could work too. – bigjosh Nov 24 '15 at 21:52
• I just tested it with the multimeter, and yes the lines are about 5 volts. What do you mean by "scan lines"? Is there some signal going across the pins? – Mac Mansfield Nov 25 '15 at 0:09
• The keys in your keyboard are connected in a matrix, as shown in the answer to your other question. The machine puts 5 volts on each column of the matrix in sequence, and then looks to see if any of the rows light up. This way, it can determine which key (if any) is pressed. If you connect the cols to input pins on your arduino, and the rows to output pins, you will be able to write a program that watches to see when the machine is checking each column so you can light up the correct row and thus make the machine think the corresponding key has been pressed. Make sense? – bigjosh Dec 1 '15 at 15:18

You can use two CD4051 8:1 analog multiplexers with their common pins tied together. One MUX connects to up to 8 row lines and the other MUX connects up to 8 column lines. You will need to control it using 3 bits for row MUX, 3 bits for column MUX, and 1 bit for the MUX enable pins.

So let's say you want to simulate a key press that connects row 3 to column 4. You would drive the row MUX with a 3 (011), the column mux with a 4 (100), and then drive INH pin to enable the MUXs for some time.

The funny thing is, I did this very same thing when I was a kid to interface a proper keyboard to my Atari 400 (which had a membrane keyboard). 33 years later, you can still use the same design. :) There was no such thing as a microcontroller back then so I used keyboard that output an 8-bit value with each keypress and then the 8 bits drive the address lines of an EEPROM. And the data lines drove the 2 analog MUX'es. So basically the EEPROM acted as a lookup table that converted a key press code to a row/column matrix connection.

Hope that helps, -Vince