History
The history of the Gray code can be traced back to a time when digital logic circuits were constructed from vacuum tubes and electromechanical switches, called relays. Incrementing the counters used to control these circuits generated enormous power demands and electrical noise when many bits were changed at once. However, by using Gray code counters, any increment changed only one bit at a time, regardless of the size of the number, and eliminated these adverse effects.
Analog to Digital Conversion
Gray's primary interest in the code was for the purposes of what is now known as analog to digital conversion. Gray sought to convert an analog voltage into a series of pulses representing the same voltage in digital form. He did so by using the voltage to disturb the path of a beam of negatively charged particles, called electrons, in a device known as a cathode ray tube. The screen of the cathode ray tube was etched with a mask that only allowed the electron beam to pass, and generate an electrical current, in certain places. Hence, the electron beam created a series of on/off conditions corresponding to the applied voltage.
Properties
Gray demonstrated not only that adjacent numbers in the Gray code sequence differ by only one bit position, but also that the Gray code is cyclical. In other words, apart from the leading bit, the second half of the code is same as the first, but reversed. These properties are central to the most common practical use of the Gray code, namely to convert the rotational position of a shaft or disk into digital form. A radial line of optical or electrical sensors read a pattern representing the Gray code from the shaft or disk and, because each value in the code differs by only one bit, the value read is guaranteed to be valid.
Scope
Strictly speaking, Gray introduced a standard, or canonical, binary single-distance code, but the term is often used to mean any number system -- including those with bases other than 2 -- in which adjacent numbers differ by 1 in one digit position only. Gray did mention, in his patent, that other binary single-distance codes could be obtained by manipulating the code table for the Gray code, but these represent just a fraction of all possible single-distance codes.