File tree Expand file tree Collapse file tree 1 file changed +45
-1
lines changed
Expand file tree Collapse file tree 1 file changed +45
-1
lines changed Original file line number Diff line number Diff line change 1- # MicroPython-SimpleKeypad
1+ # MicroPython Simple Keypad
2+
3+ ![ MicroPython] ( https://img.shields.io/badge/MicroPython-Ready-brightgreen.svg )
4+ [ ![ License] ( https://img.shields.io/badge/License-MIT-blue.svg )] ( https://opensource.org/licenses/MIT )
5+
26MicroPython library for interfacing with a keypad matrix
7+
8+ ![ ] ( https://github.com/PerfecXX/MicroPython-SimpleKeypad/blob/main/doc/4x4keypad.png )
9+
10+ ## Feature
11+
12+ - Supports any keypad matrix configuration.
13+ - Easily customizable for different keypad layouts.
14+ - Provides exception handling for error management.
15+
16+ ## Example Usage
17+
18+ Example for 4x4 keypad metrix on MicroPython esp32.
19+
20+ ``` python
21+ from machine import Pin
22+ from keypad import Keypad
23+ from time import sleep
24+
25+ # Define GPIO pins for rows
26+ row_pins = [Pin(25 ),Pin(26 ),Pin(27 ),Pin(14 )]
27+
28+ # Define GPIO pins for columns
29+ column_pins = [Pin(23 ),Pin(22 ),Pin(19 ),Pin(18 )]
30+
31+ # Define keypad layout
32+ keys = [
33+ [' 1' , ' 2' , ' 3' , ' A' ],
34+ [' 4' , ' 5' , ' 6' , ' B' ],
35+ [' 7' , ' 8' , ' 9' , ' C' ],
36+ [' *' , ' 0' , ' #' , ' D' ]]
37+
38+ keypad = Keypad(row_pins, column_pins, keys)
39+
40+ while True :
41+ key_pressed = keypad.read_keypad()
42+ if key_pressed:
43+ print (" Key pressed:" , key_pressed)
44+ sleep(0.1 ) # debounce and delay
45+ ```
46+
You can’t perform that action at this time.
0 commit comments