![]() ![]() We now arrive to the main function, which reads keypad input. For this reason, scanning the matrix with the same order of keypad PINs will require a reverse map definition: key_map=,\ In the same way, PINs from 5 to 8 identify rows in a reverse way from bottom to top. Comparing to matrix circuits, PINs from 1 to 4 identify columns in reverse order (from right to left). Keypad map will create a resolution list able to use indexes to give back the related key. In the next code lines, GP PINs are set accordingly and arrays numbers are changed with Pin objects: for x in range(0,4):Ĭol_list = Pin(col_list, Pin.IN, Pin.PULL_UP) ![]() On the other hand, column values will be read for intercepting user inputs, so having columns working in input mode. We’ll use rows to scan the matrix keypad, so having rows working in output mode (with the default values to high=1). If you use a different wiring on RPI Pico, you have to set here correct numbers: col_list= The following part uses my wiring settings, according to Pico GP naming (please refer to Raspberry PI Pico pinout). Next, we associate PINs mapping to 2 list variables so that we can manage them in a simpler way. The following paragraphs will explain it.Īs for every MicroPython script, we start importing the required modules: from machine import Pin Connect RPI Pico to Thonny (you can refer to my tutorial about the First steps with Raspberry PI Pico).ĭownload the pico4x4MatrixKeypad.py MicroPython script. Prepare cabling according to the previous paragraph.
0 Comments
Leave a Reply. |