From f11e541c090479c287af77ca1e55f10c0bf8ed3b Mon Sep 17 00:00:00 2001 From: Pat Beirne Date: Mon, 9 Dec 2024 12:40:33 -0500 Subject: [PATCH] Update 'keypad_to_microcontroller.md' --- keypad_to_microcontroller.md | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/keypad_to_microcontroller.md b/keypad_to_microcontroller.md index 7faa421..df3dd3a 100644 --- a/keypad_to_microcontroller.md +++ b/keypad_to_microcontroller.md @@ -1,13 +1,8 @@ ---- -title: Keyboard Scanning -author: Pat Beirne -date: Dec, 2024 -version: 1.0 ---- +# Keypad Scanning There's a dozen ways to connect a keyboard to a microcontroller, and this paper attempts to enumerate many of them. There are similar articles on the internet [[see below](#ext_ref)], -but this paper introduces some new techniques: [row-grounded](#3x4gnd), +but this paper introduces some new techniques: [row-grounded](#3x4-plus-ground-[new-design]), [row-grounded-with-diodes](#3x4diodes), [row-grounded-with-4-diodes](#3x4double_diodes) @@ -27,7 +22,8 @@ Sometimes, this is appropriate if the keypad is small or in an awkward location, In this document, *n* refers to the number of keys that are in the keyboard. The letter *k* refers to a specific key that is being pressed during an explanation. -## One per Pin + +## One per Pin The simplest way to connect keys to a microcontroller is one key to one pin. Connect the other side of the key to ground. @@ -60,7 +56,8 @@ microcontrollers have an A/D converter, and that can be used to determine which A naive approach would be to simply use equal-valued resistors, and then each tap would be *k*/(*n*+1) of the supply voltage. -### 3x4 Chain + +### 3x4 Chain Sometimes a keyboard will be pre-wired as a grid, so you don't have access to the individual keys. You can still use the resistor ladder to determine the key-press. @@ -164,7 +161,8 @@ The resulting 4 groups of 3 bits indicate the state of the keyboard; 1=open, 0=k Again, the same logic will allow you to manage a 4x4 keyboard with 7 GPIO pins. -### 3x4 plus Ground and 2 Diodes [new design] + +### 3x4 plus Ground and 2 Diodes [new design] Again, we can scrape off one more GPIO if we can add a pair of diodes to the row pins. @@ -217,7 +215,8 @@ look for the symbol **FIVE_PIN**. This configuration is also interrupt-capable, by setting the row drivers to output-low, and the columns as input+pullup+interrupt. -### 3x4 plus Ground and 4 Diodes [new design] + +### 3x4 plus Ground and 4 Diodes [new design] As an extreme, you can decode a 3x4 keypad with only 4 GPIO pins, using 4 external diodes.