MikeSound has created the midiGPIO MIDI to arbitrary hardware I/O interface.

Often in music or art projects, sensors are used to trigger audio or other events via MIDI, and sometimes in the other direction too. For example, a sound effect of a door creaking that triggers when as it opens on stage, or turning on lights in response to the playing of a particular note. The self-contained unit provides four 3.3V inputs and four 3.3V outputs, and supports USB and serial MIDI. When a rising edge is detected on an input, a MIDI Note-On message is sent; similarly, a Note-Off is sent on a falling edge. The input edge detection can also be used to trigger a MIDI program change. Outputs are controlled via MIDI Note-On and -Off as well.

Check out the GitHub repo for source code, schematics, and more detail.