You've mentioned that you see the value fluctuating by 1. Let's assume for now that this is due to physical limitations in the measurement.
For a binary code, you could get unlucky in some situations. Say you are stopped almost exactly on the transition between values 15 and 16 (in binary, 01111 and 10000). So it is switching between the two values. However, the bits cannot all switch at exactly the same time, for a number of reasons (mechanical/optical/electrical). The time that they switch can be made to be very close, but sometimes the next circuit will get a value with only some of the bits from each value. This is like randomly choosing a bit value for each bit. For example, it could read 01001, or a value of 9. This is not even close to the desired values of 15 or 16.
On the other hand, using a Gray code, only a single bit will change between 15 and 16. I don't know offhand what they would be, but for the sake of example take the two Gray coded values to be 01011 (15) and 11011 (16). Now, for each bit, randomly choose between the two options, and you will see that the only possibilities are the two desired values.