A rotary encoder has a disc, a pair of photo-interrupters, an adjusting member,
and a shifting controller. The disc rotates around a rotating axis and has slits
that are formed circumferentially at given intervals. Each of the photo-interrupters
has a light-emitting device and a photo-detecting device opposite one another,
and generates two signals with a phase difference. Each photo-interrupter is pivotable
around a pivot coaxial with the rotating axis, and is arranged along the circumferential
direction of the disc so as to position the slits between the light-emitting device
and the photo-detector. The adjusting member contacts the pair of photo-interrupters,
and is movable along a shifting direction corresponding to a radial direction of
the disc, so as to engage the pair of photo-interrupters. The adjusting member
adjusts a relative position-relationship between the pair of photo-interrupters
associated with the phase difference. The shifting controller shifts the adjusting
member along the shifting direction to set the phase difference to a predetermined
phase difference.