# IBM PC Keyboard to USB HID with CircuitPython

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/116/409/medium800thumb/projects_PXL_20221101_203931141.TS.mp4_2-opt.jpg?1667338231)

In this guide, you'll see how to convert an IBM PC keyboard for use on modern computers using Adafruit CircuitPython and an Adafruit QT Py RP2040 microcontroller board.

The software in this guide is only for original 83-key PC keyboard. There are also 101/102-key keyboards with the same connector, but they send multi-byte scancodes that aren't handled by the CircuitPython code.

The techniques in this guide may also be helpful in converting other classic keyboards that use a clocked serial protocol. The RP2040's "pio" peripheral is perfect for this kind of low level I/O task, and even provides a buffer for up to 8 key events so no keypresses get lost.

Since there are just a few pins used, the Adafruit QT Py RP2040 makes a solid choice of board for the project. However, there's no reason you couldn't adapt the code to the KB2040, Raspberry Pi Pico, or other board based on the same microcontroller.

Warning: The software in this guide is only for original 83-key PC keyboard (8 function keys on the side, labeled Model F. There are also 101/102-key keyboards with the same connector, but they send multi-byte scancodes that aren't handled by the CircuitPython code in this guide.

## Homework

When I saw this keyboard in a pile of stuff a friend was giving away, I recognized the classic IBM PC keyboard design with the function keys at the left hand side, and grabbed it with both hands. Good thing, too, because it weighs about 8lbs.

Being such a foundational piece of hardware, it is well documented and of course has an [extensive Wikipedia article](https://en.wikipedia.org/wiki/Model_F_keyboard). This keyboard is commonly called the "Model F", though so is the later keyboard for the IBM PC/AT. The AT Model F has a much more conventional layout and seems to be more common, so double check which one you have.

Basics of the protocol ([more detail in tmk\_keyboard](https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-XT-Keyboard-Protocol)):

- keyboard drives clock and data lines
- unidirectional communication (keyboard to pc only)
- 2 start bits
- 8 data bits
- make/break bit (keydown/keyup)
- 1 stop bit
- keyboard reset via pin 3 to ground&nbsp;

## Jeff's Verdict

I've always liked typing on buckling spring keyboards, and the feel and sound of this one are no exception. I'd have to work out alternatives for F11/F2 and the "Windows" modifier key to make it an everyday keyboard, though.

Pros:

- That classic buckling spring feel
- One of the heaviest keyboards I own
- Rare & expensive with fragile and unique keyswitches
- Seems to support full NKRO (limited to 6 keys + 3 modifiers by CircuitPython)

Cons:

- One of the heaviest keyboards I own
- Unusual location of some keys, especially F-keys and modifiers
- No caps lock / num lock indicators
- Rare & expensive with fragile and unique keyswitches

## Parts
### Adafruit QT Py RP2040

[Adafruit QT Py RP2040](https://www.adafruit.com/product/4900)
What a cutie pie! Or is it... a QT Py?&nbsp;This diminutive dev board comes with one of our new favorite chip, the RP2040. It's been made famous in the new [Raspberry Pi Pico](https://www.adafruit.com/pico) _and_ our [Feather...](http://www.adafruit.com/product/4884)

Out of Stock
[Buy Now](https://www.adafruit.com/product/4900)
[Related Guides to the Product](https://learn.adafruit.com/products/4900/guides)
![Video of hand holding a QT Py PCB in their hand. An LED glows rainbow colors.](https://cdn-shop.adafruit.com/product-videos/640x480/4900-06.jpg)

### Breadboard-friendly MIDI Jack (5-pin DIN)

[Breadboard-friendly MIDI Jack (5-pin DIN)](https://www.adafruit.com/product/1134)
To celebrate the 30th Anniversary of the invention of MIDI we're carrying these handy 5-pin MIDI jacks. They're what you see on the back of nearly every synthesizer and drum machine. These are nice sturdy jacks, and breadboard-friendly, with all the pins on 0.1" spacing for easy...

In Stock
[Buy Now](https://www.adafruit.com/product/1134)
[Related Guides to the Product](https://learn.adafruit.com/products/1134/guides)
![Breadboard-friendly MIDI Jack](https://cdn-shop.adafruit.com/640x480/1134-08.jpg)

### Half Sized Premium Breadboard - 400 Tie Points

[Half Sized Premium Breadboard - 400 Tie Points](https://www.adafruit.com/product/64)
This is a cute, half-size breadboard with&nbsp;400 tie points, good for small projects. It's 3.25" x 2.2" / 8.3cm&nbsp;x 5.5cm&nbsp;with a standard double-strip in the middle and two power rails on both sides.&nbsp;You can pull the power rails off easily to make the breadboard as...

Out of Stock
[Buy Now](https://www.adafruit.com/product/64)
[Related Guides to the Product](https://learn.adafruit.com/products/64/guides)
![Angled shot of half-size solderless breadboard with red and black power lines.](https://cdn-shop.adafruit.com/640x480/64-06.jpg)

### Premium Male/Male Jumper Wires - 40 x 6" (150mm)

[Premium Male/Male Jumper Wires - 40 x 6" (150mm)](https://www.adafruit.com/product/758)
Handy for making wire harnesses or jumpering between headers on PCB's. These premium jumper wires are 6" (150mm) long and come in a 'strip' of 40 (4 pieces of each of ten rainbow colors). They have 0.1" male header contacts on either end and fit cleanly next to each other...

Out of Stock
[Buy Now](https://www.adafruit.com/product/758)
[Related Guides to the Product](https://learn.adafruit.com/products/758/guides)
![Angled shot of Premium Male/Male Jumper Wires - 40 x 6 (150mm)](https://cdn-shop.adafruit.com/640x480/758-04.jpg)

### USB Type A to Type C Cable - approx 1 meter / 3 ft long

[USB Type A to Type C Cable - approx 1 meter / 3 ft long](https://www.adafruit.com/product/4474)
As technology changes and adapts, so does Adafruit. This&nbsp;&nbsp; **USB Type A to Type C** cable will help you with the transition to USB C, even if you're still totin' around a USB Type A hub, computer or laptop.

USB C is the latest industry-standard connector for...

In Stock
[Buy Now](https://www.adafruit.com/product/4474)
[Related Guides to the Product](https://learn.adafruit.com/products/4474/guides)
![Angled shot of a coiled black, USB-C to USB-A cable.](https://cdn-shop.adafruit.com/640x480/4474-02.jpg)

### Through-Hole Resistors - 4.7K ohm 5% 1/4W - Pack of 25

[Through-Hole Resistors - 4.7K ohm 5% 1/4W - Pack of 25](https://www.adafruit.com/product/2783)
ΩMG! You're not going to be able to resist these handy resistor packs!&nbsp;Well, axially, they&nbsp;do all of the resisting for you!

This is a **25 Pack of 4.7K Ω Resistors.** More specifically, they are **carbon film** , through-hole...

In Stock
[Buy Now](https://www.adafruit.com/product/2783)
[Related Guides to the Product](https://learn.adafruit.com/products/2783/guides)
![Angled of shot 25 Through-Hole Resistors - 4.7K ohm 5% 1/4W.](https://cdn-shop.adafruit.com/640x480/2783-00.jpg)

- [Next Page](https://learn.adafruit.com/ibm-pc-keyboard-to-usb-hid-with-circuitpython/wiring-the-adapter.md)

## Featured Products

### Adafruit QT Py RP2040

[Adafruit QT Py RP2040](https://www.adafruit.com/product/4900)
What a cutie pie! Or is it... a QT Py?&nbsp;This diminutive dev board comes with one of our new favorite chip, the RP2040. It's been made famous in the new [Raspberry Pi Pico](https://www.adafruit.com/pico) _and_ our [Feather...](http://www.adafruit.com/product/4884)

Out of Stock
[Buy Now](https://www.adafruit.com/product/4900)
[Related Guides to the Product](https://learn.adafruit.com/products/4900/guides)
### Breadboard-friendly MIDI Jack (5-pin DIN)

[Breadboard-friendly MIDI Jack (5-pin DIN)](https://www.adafruit.com/product/1134)
To celebrate the 30th Anniversary of the invention of MIDI we're carrying these handy 5-pin MIDI jacks. They're what you see on the back of nearly every synthesizer and drum machine. These are nice sturdy jacks, and breadboard-friendly, with all the pins on 0.1" spacing for easy...

In Stock
[Buy Now](https://www.adafruit.com/product/1134)
[Related Guides to the Product](https://learn.adafruit.com/products/1134/guides)
### Half Sized Premium Breadboard - 400 Tie Points

[Half Sized Premium Breadboard - 400 Tie Points](https://www.adafruit.com/product/64)
This is a cute, half-size breadboard with&nbsp;400 tie points, good for small projects. It's 3.25" x 2.2" / 8.3cm&nbsp;x 5.5cm&nbsp;with a standard double-strip in the middle and two power rails on both sides.&nbsp;You can pull the power rails off easily to make the breadboard as...

Out of Stock
[Buy Now](https://www.adafruit.com/product/64)
[Related Guides to the Product](https://learn.adafruit.com/products/64/guides)
### Premium Male/Male Jumper Wires - 40 x 6" (150mm)

[Premium Male/Male Jumper Wires - 40 x 6" (150mm)](https://www.adafruit.com/product/758)
Handy for making wire harnesses or jumpering between headers on PCB's. These premium jumper wires are 6" (150mm) long and come in a 'strip' of 40 (4 pieces of each of ten rainbow colors). They have 0.1" male header contacts on either end and fit cleanly next to each other...

Out of Stock
[Buy Now](https://www.adafruit.com/product/758)
[Related Guides to the Product](https://learn.adafruit.com/products/758/guides)
### USB Type A to Type C Cable - approx 1 meter / 3 ft long

[USB Type A to Type C Cable - approx 1 meter / 3 ft long](https://www.adafruit.com/product/4474)
As technology changes and adapts, so does Adafruit. This&nbsp;&nbsp; **USB Type A to Type C** cable will help you with the transition to USB C, even if you're still totin' around a USB Type A hub, computer or laptop.

USB C is the latest industry-standard connector for...

In Stock
[Buy Now](https://www.adafruit.com/product/4474)
[Related Guides to the Product](https://learn.adafruit.com/products/4474/guides)
### Through-Hole Resistors - 4.7K ohm 5% 1/4W - Pack of 25

[Through-Hole Resistors - 4.7K ohm 5% 1/4W - Pack of 25](https://www.adafruit.com/product/2783)
ΩMG! You're not going to be able to resist these handy resistor packs!&nbsp;Well, axially, they&nbsp;do all of the resisting for you!

This is a **25 Pack of 4.7K Ω Resistors.** More specifically, they are **carbon film** , through-hole...

In Stock
[Buy Now](https://www.adafruit.com/product/2783)
[Related Guides to the Product](https://learn.adafruit.com/products/2783/guides)

## Related Guides

- [Adafruit QT Py RP2040](https://learn.adafruit.com/adafruit-qt-py-2040.md)
- [LEGO Set Lighting](https://learn.adafruit.com/lego-set-lighting.md)
- ["Mother of all Demos" USB Keyset](https://learn.adafruit.com/usb-keyset.md)
- [Tandy 1000 Keyboard to USB with CircuitPython](https://learn.adafruit.com/tandy-1000-keyboard-to-usb-with-circuitpython.md)
- [3D Scans for Low Poly Statues](https://learn.adafruit.com/low-poly-3d-scans-for-3d-printing.md)
- [USB MIDI Host2Host](https://learn.adafruit.com/usb-midi-host2host.md)
- [SNES Mouse to USB HID with CircuitPython](https://learn.adafruit.com/snes-mouse-to-usb-hid-with-circuitpython.md)
- [MIDI Breath Controller](https://learn.adafruit.com/midi-breath-controller.md)
- [NeXT Computer Keyboard to USB HID with CircuitPython](https://learn.adafruit.com/next-computer-keyboard-to-usb-hid-with-circuitpython.md)
- [An Introduction to RP2040 PIO with CircuitPython](https://learn.adafruit.com/intro-to-rp2040-pio-with-circuitpython.md)
- [PowerWash Simulator Nozzle Controller](https://learn.adafruit.com/powerwash-simulator-nozzle-controller.md)
- [Adafruit CircuitPython Wii Classic Controller Library](https://learn.adafruit.com/adafruit-circuitpython-wii-classic-controller-library.md)
- [Lemon Mechanical Keypad](https://learn.adafruit.com/qtpy-lemon-mechanical-keypad-macropad.md)
- [CircuitPython MIDI to CV Skull](https://learn.adafruit.com/circuitpython-midi-to-cv-skull.md)
- [Halloween Neon LED Signs](https://learn.adafruit.com/halloween-neon-led-signs.md)
- [QT Py RP2040 USB to Serial MIDI Friends](https://learn.adafruit.com/qt-py-rp2040-usb-to-serial-midi-friends.md)
