0

XY-problem

I have a keyboard that consists of two halves. Each half uses 16 pins. The pins in each half are aligned in a 8x8 matrix yielding 64 key presses that can be detected, and two times 64=128 keys in total. I can set a value on GPIO pin 8, and then read out the value on GPIO pin 9 to determine whether the key on the intersection of 8 and 9 is pressed. The values are identical if there is a connection between GPIO pin 8 and 9. A keypress realises such a connection.

Example Code

After using the following script to detect a connection between two GPIO pins (GPIO pin 8 and GPIO pin 9) on a Raspberry Pico:

from machine import Pin
import time

led = Pin(15, Pin.OUT) output_line= Pin(8, Pin.OUT) input_line = Pin(9, Pin.IN, Pin.PULL_DOWN)

while True: time.sleep(2) if(input_line.value()): led.toggle() time.sleep(0.5) print("connected") output_line.value(1) print("set high")

Issue

The pico however does not have 2 times 16 GPIO pins but 26 (25 excluding the led I think). Which means it does not have enough pins for two 8x8 matrices (which require two times 8+8=32 pins). So I am looking for another 7 pins that I can set values to, or read values/connections from on other pins, to get 32 pins on which the two keyboard matrices connections/keypresses can be detected.

Solution Attempts: Software

So I tried setting the value of pin 25 and reading out the value of pin 26, however, that disconnects the Pico when I try to find that connection, for example when I connect GPIO27_A1 to AGND.

Solution Attempt: Software Example

An example I had in mind was: I assume the 3V3 sets some value/voltage, e.g. 3 Volts. I assumed that if I connect the 3V3 pin to a GPIO pin 10, and read out the value of 10, it would be False if it is not connected to 3V3, and True if it is connected to 3V3. If those assumptions are valid, that would grant me another row/pin from which I can read off key presses.

Solution Strategy: Hardware

So I could either buy cables that allow me to connect two jumper cables to a single pin, and then send those pulses/values to the left and right half of the keyboard, (multiplying the signals of the first 8 GPIO pins by two), and using another 16 pins to read out the values.

However, I was having some difficulty in finding single female to double female jumper cables, and thought it would be more elegant to not buy extra material if I can squeeze the functionality out of the board itself.

Question

Hence, I would like to ask: Is it possible to also determine connections*/(logic levels) between non-GPIO pins (and GPIO pins) in some way?

*This assumes that I am aware that there is just a single wire going from one pin to another, meaning, if the values/voltages on two pins is identical (and manually set on 1 of the two), I assume there is a connection.

a.t.
  • 171
  • 2
  • 10
  • 1
    I think you have a got a bit lost explaining your method for solving some problem. What is the problem? What are you trying to actually achieve? – joan Jan 13 '22 at 10:36
  • Thank you, I included the XY problem at the top to provide the context. – a.t. Jan 13 '22 at 10:57
  • You have asked variants of this question before. You have already been told it is NOT POSSIBLE to detect connections between pins. GPIO can detect logic levels (a few Pico pins can detect analog, but this is a red herring). Again you have been told key scanning is a common technique - you should find hundreds of examples. Basically you scan 8 pins in turn and detect on another 8. No one is going to write your code for you. The Pico has 26 × multi-function GPIO pins - more than enough. – Milliways Jan 13 '22 at 11:06
  • Thank you for indicating I did not convey my question clearly. Though similar, this question is different from the others. 1st I asked how to detect connections between GPIO pins, then I asked if its safe to connect arbtrary pins in arbitrary setups. This question is on whether non-GPIO pins can also be used to detect connections. It is not asking for code, it asks for insight. – a.t. Jan 13 '22 at 11:23
  • Ah, the way to go is using a 'matrix': https://raspberrypi.stackexchange.com/questions/104066/rpi-gpio-python-pad4pi-module-for-interrupt-based-matrix-keypad-where-is-the-i – tlfong01 Jan 13 '22 at 11:29
  • What is the end application, it appears to be a continuity or cable tester. If speed is not critical there are many I2C parts that will give you 8 or 16 iopins (PCF857 (4) (5), you can put at least 8 on an I2C bus which only requires two wires from your computer. Looking at this as an X-Y problem, none of the Xs will connect with another X and same for Ys. If so you can parallel the Xs or Ys and save 8 pins. More information always helps to get a better answer as does a schematic and links to technical information on hardware parts. – Gil Oct 12 '22 at 17:11

1 Answers1

0

While ever you continue to think about connections rather than INPUTS, OUTPUTS & logic levels you are going to have difficulty. Magic thinking e.g. non-GPIO pins (whatever they may be) won't help. Connections are a derived concept from data.

You need to stop thinking like a marketer and start thinking like an engineer.

It now appears that you have an (unreferenced) keyboard with 2 8*8 matrices.

To an engineer this suggests you need 8 OUTPUTS & 16 INPUTS.

If I were doing this in MicroPython I would create 16 Pin.irq handlers for the inputs and poll each of the 8 outputs with a suitable delay.

Milliways
  • 59,890
  • 31
  • 101
  • 209