Raspberry Pi practice problem · Buttons & input
Number entry
MediumBudget $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.
Build a little number-entry field:
- digit keys add a digit to the entry
*deletes the last digit (backspace; nothing happens on an empty entry)#prints the entry and clears it:Entered: 425— orEmptyif nothing was typed- the letters A–D are ignored
Each key counts once per press, however long it is held. The test types 427*5# from 1.0 s, # at 3.5 s, then 0A8# from 4.5 s.