PURPOSE: To obtain an extremely thin encoder by arranging plural N-type or P-type semiconductors movable relatively as being brought into contact with P-type or N-type semiconductor pieces keeping an equal interval in a travel direction.
CONSTITUTION: When a rotary shaft 12 rotates and the N-type semiconductor piece 11 is located between the P-type semiconductor pieces 5 and 8, the semiconductor pieces 5, 11, and 8 constitute a PNP transistor, and an electrode 14 functions as a base terminal, and an electrode 9 as an emitter terminal, and an electrode 6 as a collector terminal. Therefore, a switching current flows by a voltage impressed from the electrode 14 advancing to the electrode 9. When the rotary shaft 1 rotates further and a movable insulating substrate 10 is interposed between the semiconductor pieces 5 and 8, no transistor is formed, and a base current and the switching current are cut off. Thenceforth, the switching current repeats ON/OFF with a period decided by a pitch S according to the rotation of the rotary shaft 1, and the amount of rotation of the rotary shaft 1 is detected based on the ON/OFF of the switching current.