Updated!!..  PC Keyboard Page

This page came about through searching for info on the Keyboard to PC serial link, when I was writing some keyboard interfacing code for the PIC. The page is mainly links as I'm not going to repeat information that can be found elsewhere. Note that some of the information on those pages is not correct, or ambiguous, so cross check the info.

NOTE - I may be able to answer questions about PC keyboard H/W and interfacing - I have no knowledge, however, about PC S/W even if it's to do with keyboards


PICKeyboard View Software and Circuit - My PC AT keyboard code viewer; uses a 16C84 and 20x2 LCD display (can use 16, 24, 32, or 40 x 2 LCD displays by changing one line). Also gives example LCD driver code, queuing code, and wait macro. (Ver 1.11).

Qs and As

Q - What goes down the cable from the keyboard to the PC?

A - Although the connectors have 5 or 6 pins, there are only four connections;

Q - Is the codes on the keyboard serial cable the same as the scan codes you use when writing 'C' programs, or ASCII?

A - Nope, Totally different from both. There's no logic to them; therefore the easiest way to deal with them is to use a look-up table.

Q - What are the codes for the 3 extra keys on a 'win95 105 keyboard?

A - According to my PC keyboard code displayer, in Mode 2 they are:-

They may be affected by Num Lock (by adding Left Shift on either end ie E0,12,.. on press, ... E0, F0, 12 on release). The Aminet PC keyboard to Amiga code in the link below states them as well, but I couldn't work out what they were.


The Connectors

Looking at the pins of the plug:-
(or the wires of a socket)

din6 pinout Apologies if these graphics do not show on your default background colour.
1 - DATA, 2 - n/c, 3 - GND, 4 - +5V, 5 - CLOCK, 6 - n/c


Looking at the pins of the plug:-
(or the wires of a socket)

din5 pinout
1 - CLOCK, 2 - DATA, 3 - n/c, 4 - GND, 5 - +5V


Links

PC keyboard emulator by Tony Kubek

AT keyboard routines (both ends) on Mauricio Culibrk's PIC page, for if you want a PC keyboard connected to a PIC project, or a PIC project to connect to a PC. Also a link to a keyboard FAQ that is very clear

Apologies - DEAD Link - Was "http://www.enterprise.ca/~jbilous/kybrdidx.htm" - or Tomi Engdahl's computers and microprocessors page(then FIND 'keyboard') - Links to various keyboard info. inc. links to a good document on interfacing the keyboard and to AT controlling code for the 6502

Philips Ap Note 434 (PDF) or Philips Ap Note 434 (GIF) gives the 80C751 (8051 family) microcontroller code for a PC AT keyboard to I2C converter.

Atmel App Note AVR313 (PDF) has info. and code (in C) to interface a PC AT keyboard to the Atmel AVR range.

Aminet/hard/hack (also in the hard/hack dir of other Aminet mirrors) gives the 8051 microcontroller code for the PC keyboard to Amiga converter which can handle win95 keyboards

KEYBTST.ZIP gives a very basic program for the parallax BASIC stamp II, to send key-codes to the PC's keyboard port. It also gives a write-up of the XT and AT keyboard interfaces (although IMO some details could be wrong / different to the keyboards I've looked at).

This Mail from Roger Coleman gives a snippet of code for the PIC microcontroller, for decoding alphanumeric keyboard codes .

Try also:-

www.repairfaq.org/gilipg/LINK/PORTS/F_Keyboard_FAQ.html
How to interface an AT keyboard to a system expecting ASCII input
PIC 16C84 Routine
hth.com/filelibrary/TXTFILES/keyboard.txt
www.geocities.com/SiliconValley/Bay/8302/keybrd.htm
nyquist.ee.ualberta.ca/~jdv/
www.barcodeman.com/scan_doc.html
a repeat of an FAQ
(thanks to Mark Willis and James Newton for some of these links)

The IBM PC reference manual, section 4 also has good material.


Back to Projects index

If you want more information, Mail Me

Last Updated by Steve Lawther on Saturday, 3 July, 1999 at 7:08 PM.