Gray code, also known as reflected binary code, expresses all its values as a sequence of 1s and 0s. Unlike binary code, each value differs from the previous one by only a single bit. This has many practical applications, particularly where multiple simultaneous bit changes would result in errors. Gray codes can have any number of bits, and new Gray codes can be calculated from binary codes that have one bit less than the proposed Gray code.

Decide on the number of bits that will make up your Gray code. For example, suppose you want a Gray code that is 3 bits long. The number of bits determines how many different values the Gray code can represent. To find out how many values a Gray code can represent, raise 2 to the power of the number of bits that make up the code. For example, a 3bit Gray code can represent eight different values.

Write out the binary code for a sequence that is 1 bit less than your Gray code (see Resources for more on binary code). If your Gray code has 3 bits, you will write out the binary code for a 2bit binary code, like this:
00, 01, 10, 11

Add a leading zero to all the numbers in the sequence you just wrote, like this:
000, 001, 010, 011

Write the binary code again in reverse order, like this:
11, 10, 01, 00

Add a leading one to all the numbers in the sequence you just wrote, like this:
111, 110, 101, 100

Concatenate the two lists together. You now have a 3bit Gray code, which looks like this:
000, 001, 010, 011, 111, 110, 101, 100
References
 Photo Credit Jupiterimages/Photos.com/Getty Images