10

I have an old laptop keyboard like the one shown below: old laptop keyboard

It has a 24-wire flat cable coming out of the back. Would it be possible to use this as a keyboard for the Pi (I assume with some microcontroller in between)?

Jakob Weisblat
  • 175
  • 1
  • 2
  • 10

5 Answers5

11

There is no easy or simple way to achieve what you ask. The simplest answer is just ignore this keyboard and get a USB one.

However, if you really want to do it, it's a DIY job through and through. Your solution will be custom to this keyboard and may or may not be easily adapted to accommodate keyboards from other manufacturers.

Laptop keyboard connectors are not standard. They vary across manufacturers. Typically, they also lack any electronics to process the keypresses and convert them into simpler data messages, e.g. key codes or button codes etc.

Therefore, first you need to figure out what happens each time you press a key, i.e. which electrical signals get activated (get shorted together).

Then you have two options, both very tricky:

Option 1 - Very advanced:

You need to construct an electronic interface which will connect between the keyboard and the USB port on the Pi. It needs a microcontroller to emulate a USB keyboard when it's plugged into the USB port and you will need to write software to map the key pressing signals into USB keyboard presses. The microcontroller needs to do all the work. You might want to read this related question: Can I make a full USB keyboard with Makey Makey + Raspberry Pi

Option 2 - Insanely advanced:

Raspberry Pi has a connector with 17 GPIO (general purpose input output) pins. You need to design a circuit to reduce the 24 keyboard lines and interface them to the GPIO pins. Then you need a custom keyboard driver for the Pi operating system.

Hint:

Some of the 24 connector lines will be inputs and others outputs. Each time a key is pressed, some of the inputs connect to some of the outputs. Some of the lines may be unused. It will take patience and a continuity checker to figure out exactly what happens. Also consider searching for keyboard encoder chips. This is an example: http://www.ti.com/product/tca8418e These chips take out the hard work of encoding.

2

Sorry to reply to such an old thread, but you can achieve this with an old USB keyboard controller.

I haven't tried it yet, but I believe this should be possible. Simply line up the connectors on the ribbon cable with those of the keyboard controller and hold it in place with the cap (make sure it has the same amount of connectors, it usually does). If the ribbon cable is too small, get an adapter.

Emil
  • 29
  • 1
2

I have few laptop keyboards and I really want to use them... So what I can see those with 24 wires are keyboards without numeric pad while keyboards with numeric pads have 26 wires.

I have torn down one broken keyboard to see how it is made. From what I have seen there are two sheets of foil with paths and connection/button points divided with one foil as a separator. Each wire is allocated to few buttons on one sheet and connects to the second sheet and other wire. I have checked the number of available combinations https://www.hackmath.net/en/calculator/combinations-and-permutations?n=24&k=2&order=0&repeat=0 look's like we have 276 possible combinations.

Because there are many keyboards and they have different combinations best way is to make a small program that asks you to press a specific button and record which wire-wire combination is associated with that button.

Since Rpi has only 17GPIO as Vassilis mentioned it will be hard to do it because you need something in between, but there is Arduino (Mega = 54 IO)and it can help at least to decode button/wire pair combination. I need to look on laptop boards what ic are used as the controller to see if we can use it, is it programmable etc.

Anyway, it is possible and probably not that hard but of course normal people would just buy a USB keyboard.

Kaik
  • 21
  • 1
1

Some keyboards might have a controller of some sort. If they don't have a controller, then all of the keys are wired up in a key matrix. Pushing a key will connect one column and one row together. Most controllers will scan through the columns and look to see what rows go high to find which keys are pressed. One thing you might try is getting a Teensy arduino and programming it with the usb keyboard firmware. You'll have to figure out how all of the keys are wired up though. The Teensy can convert it to USB to plug into the Pi. There's a lot of technical skill required to do this, it's not for the faint of heart.

JamesH
  • 111
  • 1
1

I used a Teensy ++2.0 as a keyboard controller for a Sony Vaio that I converted to a Raspberry Pi Laptop. An ohm meter was used to figure out the key matrix and Teensyduino code was written to scan the matrix and send the key codes over USB. The Teensy also controls the touchpad over PS/2 and sends the results over the same USB cable. Using an ohm meter to figure out which signals on the keyboard cable are connected is very time consuming and prone to error (you need 3 hands, good eyes, and a lot of time). To make it easier for people to re-use a laptop keyboard, I wrote an Instructable that describes the step by step process to build a keyboard controller using a Teensy LC or 3.2. The Teensy is first loaded with a routine that reports which pins are connected when a key is pressed. From this, you can build a key matrix table that can be added to a new Teensy routine that acts as a keyboard USB controller. I have converted over a dozen laptop keyboards to USB using this method. You will need to send my Eagle board file to OSH Park to have the circuit board fabricated. The board provides pads to solder a keyboard connector that is routed to a Teensy microcontroller. This project is definitely more advanced than your basic plug and play Arduino project but it's worth the effort if you want to re-purpose an old laptop with a Pi and keep the original keyboard and touchpad.

  • If I remember correctly, a Teensy costs around $20, so unless the OP is really interested in the keyboard more than in the RPi, buying a new keyboard would save both time and money. – Dmitry Grigoryev Jan 21 '19 at 08:45