... See, the blackpill is precoded and setup to directly connect to a button matrix like in the picture. An IIC bus wouldn't work for that reason.
Furthermore, I don't need to scan for 24 buttons. I need to scan for 5 pins and digitally write 5 other pins in order to simulate 25 button presses.
If you cannot change the code in one location (the blackpill), then you need to directly emulate a matrix,
thus you may need two MCUs whose code you can control, on each side of the slip ring.They can be identical, and you could even have one hex file for both, by using a pin to select RX or TX
The 5 input pins fire sequentially after each other but the length of the pulses differ allot between cycles making it hard to predict when a certain pin is going to be active...
The problem is that the pulldowns on the blackpill happen seemingly randomly, differ in length, and the reading on the blackpill happens at the beginning of the pulldown. This means that the nano needs to respond within a microsecond in order to fire on time. I tried to use port manipulation on the nano in combination with interrupts but even when only using one read pin instead of five it is still to slow. I hope that there is maybe a faster way.
That may be due to the MCU running other interrupts, and usually keypad scan does not care about ms of jitter.
If you run a pin change interrupt on every line, you should be able to auto-sync to any jitter.
Assembler should be faster, but if even assembler is not fast enough, another approach is to delay from the earlier edge, long enough so that the first sense point is ignored, and the desired (next) one is caught. ie you pull low
earlier than the keyboard checks.