πΎ Archived View for shit.cx βΊ keyboards βΊ h0002 βΊ 2020-12-28-keyboard-circuit captured on 2024-08-31 at 11:41:44. Gemini links have been rewritten to link to archived content
β¬ οΈ Previous capture (2022-07-16)
-=-=-=-=-=-=-
2020-12-28T00:21
Soon I'll be wiring up the keyboard, so I figure it must be time to explain the circuit.
I use a TeensyΒΉ microcontroller with the TMKΒ² firmware to drive the circuit. TMK scans the switches, then sends the state of the switches to the host while presenting itself as a standard USB HID keyboard.
To maximise the number of switches that can be driven from the very finite pin-count of a Teensy, the switches are arranged into a matrix of rows and columns. As you increase the size of the matrix, you gain pin-usage efficiency; a 8x8 matrix needs 16 pins to drive 64 switches where a 2x2 matrix needs 4 pins to drive 4 switches.
The matrix is scanned a little like this:
for r in rows { set_high(r); for c in columns { is_high(c) && send_key(r,c); } set_low(r); }
An overly simple circuit might look like this:
CΒΉ CΒ² β β RΒΉβββ¬ββββββ βββ β βββββββ€ βββββββ€ β β RΒ²βββ¬ββββββ βββ β βββββββ βββββββ
You then assign letters to the switches. In this example, we will map them as such:
RΒΉCΒΉ: A RΒΉCΒ²: B RΒ²CΒΉ: C RΒ²CΒ²: D
But this circuit has a problem. When B, C and D are simultaneously pressed (like below), it incorrect detects that A has also been pressed.
CΒΉ CΒ² β β RΒΉββββ¬βββββ ββββ β A ββββββ€ B ββββββ€ β β β β RΒ²ββββ¬βββββ ββββ β C ββββββ D ββββββ
This is because while scanning RΒΉ, the signal takes a path through the B switch, then passes the wrong direction through D, then finally passes through the C switch causing CΒΉ to read high.
This problem can only arise when a signal passes the wrong way through a switch. To prevent this, we use diodes.
CΒΉ CΒ² β β RΒΉββββ¬ββββββ ββββ β A ββββββΆβ€ B ββββββΆβ€ β β β β RΒ²ββββ¬ββββββ ββββ β C ββββββΆβ D ββββββΆβ
If you can understand that, then there's really nothing to it. The hardware to wire up a keyboard is easy and with the help of TMK, the software has been taken care of for you.
---
The content for this site is CC-BY-SA-4.0.