Binary to Gray Code

This circuit uses only logic gates there is no programming. It converts from binary to gray code and vice versa. The right two sets of switches are the 8-bit input and the left set of dip switches if any of them are on it will take a gray code input and give you a binary output otherwise the input is binary and the output is gray code. In total this circuit uses 20 NAND gates and 7 XOR gates to compute the output.

For anyone who is wondering instead of using each location as a value like with binary, gray code is designed to be easy to advance from one value to the next when inputting data with switches. So when counting up you only flip one switch to increase your number by one. This is a lot easier because when you advance from number 15 to 16 in binary you have to flip 5 switches, where as gray code you only have to flip one.

The example in this picture is converting between binary:
   00101010 (the switches)
and gray code:
   00111111 (the LEDs)