Problem with KMKfw libraries

Joined
May 10, 2023
Messages
1
Reaction score
0
I have very little experience with programming, so bear with me.
I'm trying to do the example shown on KMKfw's "Getting Started" page (http://kmkfw.io/docs/Getting_Started/), but after creating the code.py file and pasting the example code, it's giving me an error.
I already installed Circuit Python onto my Raspberry Pi Pico RP2040, and I'm using Mu 1.2.0 to edit the file that the example code is on ~ code.py.

This is the error message:

code.py output:
Traceback (most recent call last):
File "code.py", line 18, in <module>
File "kmk/kmk_keyboard.py", line 473, in go
File "kmk/kmk_keyboard.py", line 497, in _init
File "kmk/kmk_keyboard.py", line 337, in _init_matrix
File "kmk/scanners/keypad.py", line 52, in init
TypeError: object of type 'Pin' has no len()

Code done running.

-----------------------------------------------------------------------
keypad.py has the following code at line 52:

class MatrixScanner(KeypadScanner):
'''
Row/Column matrix using the CircuitPython 7 keypad scanner.

:param row_pins: A sequence of pins used for rows.
:param col_pins: A sequence of pins used for columns.
:param direction: The diode orientation of the matrix.
'''

def init(
self,
row_pins,
column_pins,
*,
columns_to_anodes=DiodeOrientation.COL2ROW,
interval=0.02,
max_events=64,
):
self.keypad = keypad.KeyMatrix(
row_pins,
column_pins, # (Below is line 52)
columns_to_anodes=(columns_to_anodes == DiodeOrientation.COL2ROW),
interval=interval,
max_events=max_events,
)
super().init()


Has anyone else come across this while using kmkfw? I don't truly understand the len() error message, so I'm hoping someone can point me into the right direction. Thank you.
 
Joined
Mar 31, 2023
Messages
95
Reaction score
8
Based on the error message you received, it seems that there is an issue with the row_pins and column_pins parameters in the init() function of the MatrixScanner class in the keypad.py file. Specifically, the error message indicates that an object of type Pin (which is used for specifying pins) does not have a length property (len()), which is causing the error on line 52.

One possible reason for this error could be that you are passing a single Pin object instead of a sequence (e.g. list, tuple) of Pin objects for the row_pins or column_pins parameters.

Double-check that you are passing the correct parameters to the MatrixScanner constructor in your code. If you are still having trouble, you may want to consider posting your code on a platform like GitHub or Pastebin so that others can take a closer look and help you troubleshoot.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top