Working principle:_x000D_ 1. Through the optical principle to achieve: a light-emitting diode inside, the photosensitive receiving transistor two; another one of the cylindrical shade_x000D_ 2. Observe the light-emitting diodes and the light-receiving receivers through the cylindrical shading to detect the current state of the RPI-1031_x000D_ 3. When RPI-1031 is in the state shown in the figure, the light-emitting diode is blocked by the shade, two light-receiving transistor can not receive the light, in the off state, corresponding to the output low, two GPIO output are Low level_x000D_ 4. When the RPI-1031 rotation is in the state shown in the figure, one of the phototransistor is blocked, the light emitted by the light only the above-mentioned photosensitive transistor can receive, that is above the photosensitive transistor conduction, the following light Transistor off, so that the two GPIO output is a high level, one is low;_x000D_ 5. When the RPI-1031 continues to rotate in the picture state, the shade is not blocked, the diode emits light, the two phototransistors can be received, so that can be turned on, the two GPIO output are high;_x000D_ 6. When the RPI-1031 continues to rotate as shown in the figure, this state is exactly the same as described in 4, and the high and low levels of the two GPIO outputs are swapped