In the last post, I extracted the Keyboard connections from the motherboard and removed the motherboard itself, leaving an empty case to work with.
Building the hardware interface
If you are reading this as instructional for your own project, please read the whole post before following with your own project, so that you don’t have to redo any work. I’m starting with my go-to hardware platform, the Arduino. In particular, the Arduino LeoStick has caught my eye for a while and has the USB connection on the PCB – no cable! That makes it perfect for a tight space. You can find all the information you need to get it going with your Arduino IDE at the LeoStick link provided. Alternatively, the Arduino Leonardo would work just as well and is supported by the Arduino IDE as standard.
To find out how the keyboard connections worked, I found this schematic (under the ‘Keyboard Scanning’ heading), which basically gives me the following pieces of information:
- The film with 5 contacts has the Data lines
- The Data lines have pull-up resistors to +5V
- The film with 8 contacts has the Address lines
- The Keyboard is arranged in a 5×8 matrix (Data x Address)
I’ll tackle how a matrix works in the next section as I cover writing the software, suffice it to say that the important thing now is that my data lines are individually held high. To diagrammatically represent the above information:
Wiring to the Arduino
I have included the pin order for you to connect the Arduino pins in the above diagram. I recommend soldering the wires and resistors first, then placing the PCBs down where you are going to have them (mine sit in the top recess of the lid). That way you can ensure that the connectors’ metal contacts are on the side of the membrane that has the exposed connections before you solder them. The placement of the connections needed to be flexible so as not to tug or stress the keyboard membrane. As such, I cut down two blank prototyping PCBs to be big enough to attach the keyboard connectors, plus my resistors and wires to the Arduino. Personally, 10KΩ resistors are always my go-to resistor, so that’s what I used. The wires, resistors and PCB board together only cost a few pounds and are fairly easy to work with. When you do this, leave your Arduino wires longer than you need. You can shorten them once you’ve sorted out the placements of everything.
My PCBs with connectors looked like this.
The resistors on the data PCB (right) all connect from the connector to the yellow 5V wire at the top of the PCB.
The address lines are the ones changed by the controller (our independent variable) and the data lines are the ones tested (our dependent variable). So, the address lines connect to the digital pins (marked with numbers 0-13) and the data lines are connected to the analog input pins (marked A0-A4) in the above sequence.
Here are the PCBs just placed in an Arduino Uno so that you can see what it looks like wired up. If you use the Leonardo, as you may be aware, the pin layouts for the Leonardo and Uno are the same, so you can copy this exactly.
You can see the data lines in green going to the A0-4 pins, the blue address lines going to the D2-9 pins and the yellow +5v wire going to a VCC connection. I used digital pins 2-9 rather than 0-7 because digital pins 0 and 1 are used for the serial connection (Tx and Rx) which will be used by the USB connection, so in your own, leave digital pins 0 and 1 unconnected (use pins 2-9). Once soldered to the LeoStick and laid into the lid, my Spectrum-USB Arduino keyboard adapter looked like this.
At this stage I tested my soldering by setting all the pin numbers (<pin>) to output:
and then setting them to +5V:
That way, I could run over all the keyboard connections in the connectors (and the +5V side of the resitors) with a multimeter and check each for +5V, ensuring good connections. Once happy, I fixed the PCBs in line with the membrane connections using a glue gun as shown in the image above. Once you’re really happy with the placement of the connections and they are really secure then you can carefully plug the membrane back in. Since the membrane is so delicate, I kept the films as sheltered and uncreased as possible by gently packing them into the more spacious top section of the upper case as shown below. The masking tape held them flat so as to minimise movement as the case is opened and closed.
In the next post, I’ll cover writing the software to make the keyboard output the button presses to USB.