After coming back to it a day later released I was not setting my values correctly when it was running the loop for key press.
Code:
import gpiodimport timechip = gpiod.Chip('gpiochip4')# Corresponding buttons on the keypadmatrix_keys = [['1', '2', '3', 'A'], ['4', '5', '6', 'B'], ['7', '8', '9', 'C'], ['*', '0', '#', 'D']]# Pin set up using GPIO pin numberskeypad_rows = [6,13,19,26]keypad_columns = [12,16,20,21]row_pins = []col_pins = []# Define input-rows and output-columnsfor x in range(0,4): row_pins.append(keypad_rows[x]) row_pins[x] = chip.get_line(keypad_rows[x]) row_pins[x].request(consumer="RButton"[x], type=gpiod.LINE_REQ_DIR_OUT) row_pins[x].set_value(1) col_pins.append(keypad_columns[x]) col_pins[x] = chip.get_line(keypad_columns[x]) col_pins[x].request(consumer="CButton"[x], type=gpiod.LINE_REQ_DIR_IN)def scankeys(): for row in range(4): for col in range(4): row_pins[row].set_value(0) if col_pins[col].get_value()==0: print("You have pressed", matrix_keys[row][col]) time.sleep(.5) row_pins[row].set_value(1)while True: scankeys()for x in range(0,4): col_pins[x].release() row_pins[x].release()
Statistics: Posted by eflwi — Sun Nov 24, 2024 5:43 am