Arduino to trigger keyboard matrix

Hello everybody,

I have a toy keyboard which has a similar IC like in the picture below. It has a 6x6 keyboard matrix,
and when the note on the keyboard is pressed it shorts one red leg and on green leg.

For example if I press note C it shorts pin 3 and piin 11, if I press D it shorts pin 3 and pin 12 and so on.

I want to do a MIDI input for it so when I press a note C on MIDI keyboard it would short pin 3 and pin 11 on that IC.

I have figured out the matrix and wired out all the pins.

If I short the pins with the bare wire it plays the note right away.Also I figured out that the green pins are all tied to 3V rail.

I do have a MIDI to Arduino circuit. What I need is Arduino code to do this “pin shorting” action.

Test circuit with two red (Arduino pin 2, 3) and three green lines (Arduino pin 8,9,10) connected:

This is what I came across - MIDI IN circuit works and the LED flashes when a note on MIDI keyboard is pressed,but it wont trigger the toy keyboard.

#include <MIDI.h>
MIDI_CREATE_DEFAULT_INSTANCE();

int led1 = 11;
int s3 = 2;
int s4 = 3;
int d11 = 8;
int d12 = 9;
int d13 = 10;

void setup() {
  MIDI.begin(10);
  MIDI.setHandleNoteOn(MyHandleNoteOn);
  pinMode(led1, OUTPUT);
}

void loop() {
  MIDI.read();
}

void MyHandleNoteOn(byte channel, byte pitch, byte velocity) {
  
    digitalWrite(led1, HIGH);
    delay(10);
    digitalWrite(led1, LOW);
    
  if(pitch == 43){ 
    digitalWrite(s6, HIGH);
    digitalWrite(d11, HIGH);
    delay(10);
    digitalWrite(s6,LOW);
    digitalWrite(d11, LOW);
  } 
  if(pitch == 44){ 
    digitalWrite(s6, HIGH);
    digitalWrite(d12, HIGH);
    delay(10);
    digitalWrite(s6,LOW);
    digitalWrite(d12, LOW);
  }
  if(pitch == 45){ 
    digitalWrite(s3, HIGH);
    digitalWrite(d11, HIGH);
    delay(10);
    digitalWrite(s3,LOW);
    digitalWrite(d11, LOW);
  } 
  if(pitch == 46){ 
    digitalWrite(s6, HIGH);
    digitalWrite(d13, HIGH);
    delay(10);
    digitalWrite(s6,LOW);
    digitalWrite(d13, LOW);
  }
  if(pitch == 47){ 
    digitalWrite(s3, HIGH);
    digitalWrite(d12, HIGH);
    delay(10);
    digitalWrite(s3,LOW);
    digitalWrite(d12, LOW);
  } 
  if(pitch == 48){ 
    digitalWrite(s3, HIGH);
    digitalWrite(d13, HIGH);
    delay(10);
    digitalWrite(s3,LOW);
    digitalWrite(d13, LOW);
  }
}

Your picture of a rats nest of wiring is useless. Post a real schematic.

If you are trying to connect pin 6 to pin 11 when pitch is 43, setting both pins HIGH or LOW is not the way to do that.

You want the Arduino to trigger the gate on a transistor to connect the pins.

It's not going to be as easy as shorting the pins, or at least not by connecting them directly to pins on the Arduino. You'll need some external hardware for that.

There are probably 2 ways to do this...

  1. Is build some external hardware to do the pin shorting.
  2. Work out which pins are driving the keyboard matrix, and which are reading it. Then you'll need to read the output pins and drive the input ones at the correct point.

PaulS:
Your picture of a rats nest of wiring is useless. Post a real schematic.

If you are trying to connect pin 6 to pin 11 when pitch is 43, setting both pins HIGH or LOW is not the way to do that.

You want the Arduino to trigger the gate on a transistor to connect the pins.

I’m sorry for the rats nest, my bad.

Here’s how Ive planned to connect everything:

http://vvv3v.lt/schematic.jpg

Maybe you know a similar reference for connecting pins with a transistor?