Replace chip (PCB) in usb midi keyboard with arduino

Sorry but the code means little without a schematic.

You first have to verify the hardware before delving into driving it otherwise you don’t know if the problem is hardware or software.