MIDI Organ project built with an Arduino Leonardo. This connects to an Yamaha Electone FS-70 with 3x MCP23017 I/O expanders.
The code in this project is very specific to the wiring of this project. However, it serves as a practical example of how input matrix scanning can be used to generate MIDI messages over USB.
This project uses arcore for MIDI-USB on an Arduino Leonardo.
For a very good tutorial on different input matrix scanning methods, see this post on Open Music Labs.
For technical details on the Yamaha FS-70 (and other similar models), see this site by Tim Singer.