I have a project to convert an old game console to a modern USB controller. It uses a Teensy 4.1 with USB host to interface with the xbox game controller and a standard 4+4 matrix keypad using keypad.h.
The game console has a wiring harness with GND, +5v, 4+4 matrix keypad lines, a POTX, POTY and POTC (5v) for a two-axis potentiometer joystick.
The Teensy outputs to a set of 4 CD74HC4066 switches using 16 output pins for a total of 16 switches. The switch inputs (E pins) are connected directly to Teensy output pins. Low is an open switch, high is a closed switch. The 4066 outputs (Y and Z) are matrixed into 8 lines and go to the console harness.
The Teensy also has an SPI connection through a bi-directional 3.3 to 5v level shifter module to an MCP42100 digital pot. This is connected to the console POTX, POTY and POTC lines. The level shifter is connected to the Teensy 3.3v and GND and the console 5v and GND.
This is working with one problem.
The 4+4 matrix keypad attached to the Teensy picks up stray voltage when I touch it. It is not mounted yet and just handling it sometimes causes a line to go high (confirmed with a logic probe). I can see the logic probe's high LED fade in as I move my finger across the pad. This causes the 4066 switch to close and registers and a button press on the console. If I don't touch the Matrix keypad there are no stray keypresses.
It stops happening when I plug the Teensy into the computer using USB. It does not happen when the Teensy is getting all power from USB (disconnected from console) and it doesn't happen when getting power from the console and connected to the computer with USB with the USB power line cut.
It seems like it must be a ground issue but I don't know enough about electronics to know how to fix it.
Does anyone have advice on what can cause this or how I can fix it?