Revision History
January 15, 2017: Added info about existing similar work in the intro section
January 11, 2017: Added info about the first demo clip
January 8, 2017: Added section with reference material, including similar projects
January 4, 2017: Initial version
Author: Adam Podstawczyński. Feel free to use any materials in this tutorial, please send me an email if you find it useful :)
This project emulates the keyboard of Commodore 64. It allows one to send a string of characters, or interactively type in characters, from a PC/Mac/Linux computer, and have it displayed on the C64 screen.
The project is just another take on microcontroller + crosspoint switch + keyboard combination. When I built it, I was convinced nobody had had that idea before, but when I announced it I was made aware that I was not the first! Similar project are listed in the Reference Material section.
A Python script on the computer accepts text to type in various forms (e.g. interactively typed-in, from command line, redirected from other command). The script maps the text to keys or key combinations, and then as another step maps those to 6-bit binary codes. Then the codes are passed via the serial interface (here USB) to the Arduino microcontroller. A listening program on the Arduino accepts the codes and sends them as 6-bit addresses to the write-only memory of an 8x8 crosspoint switch (MT8808), along with 1-bit data. A 6-bit address + 1-bit data are equivalent to "a specific key on" or "a specific key off" command. The command is latched in the crosspoint switch using a strobe signal which results in a particular column pin being shorted with a particular row pin, i.e. effectively pressing a specific key on C64. In case of key combinations, 2 or more such address/data "words" are latched. The Restore key which is activated by connecting to ground needs a separate handling using a transistor.
(This is an older version without the Restore transistor. Also, I mistyped mt8808 as mt8088 in the clip.)
Make the following connections. If you want to use different digital pins on the Arduino, remember to adjust the numbers in the code later.
The Python script and Arduino code are currently incomplete, and have been written quickly to prove the concept. Use at your risk and expect many issues: download from github. More solid version will need some time to complete -- stay tuned.
After completing the first working prototype and announcing it on the Lemon C64 forum, I was advised of similar projects undertaken in the past (see below). All of them, however, are meant for connecting a PS/2 keyboard to C64 (either directly or via Arduino). The idea behind the project described here is to give control over C64 keyboard to the computer which opens more possibilities.
C64 Key C64 Pins C64 Ports 8088 AY2 AY1 AY0 AX2 AX1 AX0
DEL 13 12 PA0 PB0 X0Y0 0 0 0 0 0 0
3 19 12 PA1 PB0 X1Y0 0 0 0 0 0 1
5 18 12 PA2 PB0 X2Y0 0 0 0 0 1 0
7 17 12 PA3 P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