This article explains how to setup an Android device as a MIDI input device for a PC via USB cable
You need any android phone with OS version 6.0 or above
Open settings screen and tap on "Developer options"
Scroll down and locate "USB configuration" and tap on it
A popup will appear, tap on "MIDI"
Open the app and tap on the Output Icon
Tap on Android Peripheral Port
Now tap any button and enjoy the MIDI in your application
For application to receive this MIDI refer article kotlin-midi-reader-windows-rtmidi