Raspberry Pi practice problem · Buttons & input
Multi-tap texting
HardBudget $6Python · gpiozero
The keypad's rows R1–R4 go to GPIO5, 6, 13, 19 and its columns C1–C4 to GPIO12, 16, 20, 21 (layout 123A / 456B / 789C / *0#D). Scan it: drive one row low at a time, with the columns as pulled-up inputs; a low column is a pressed key.
Type text the way old phones did:
| key | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
|---|---|---|---|---|---|---|---|---|
| letters | ABC | DEF | GHI | JKL | MNO | PQRS | TUV | WXYZ |
- Pressing a letter key again within 0.8 s of its previous press cycles to the next letter (wrapping).
- The pending letter is committed when a different key is pressed, or when 0.8 s pass without a press.
- 0 commits any pending letter and adds a space.
- # commits any pending letter, prints
Text: <text>and clears the text.
The test types HI PI (4 4, pause, 4 4 4, 0, 7, 4 4 4, #) starting at 1.0 s, then OK (6 6 6, 5 5, #) from 6.0 s. Keys within a letter are 0.25 s apart.