This picture shows the very first prototype of my “octoboard” containing 8 optical sensors an ATmega16 microcontroller supplying a MIDI and an AVR-ISP interface:The schematics of it look like this and don’t contain anything unusual when you are familiar with micro controller schematics:
As you can see the sensors are infrared reflection sensors consisting of an IR-LED and a phototransistor. The current through the phototransistor is converted to a voltage by a shunt resistor. This voltage is measured by the ADC of the microcontroller where it is used to detect the position of the depressed key.
These data are used to drive a simplified physical model of a hammer mechanic. This model is used to determine when and how fast the hammer is going to strike its corresponding strings, so it does more than just measuring the velocity of the key. The result is then downscaled to the desired MIDI value range and sent to the synthesizer. Finally a photo of the mounted module in the piano case: