The specific code that Frank Gray called "reflected binary code" (1947 patent application, granted 1953) is now often labeled BRGC for "binary reflected Gray code" after him. [However such a code appears as early as 1878 with Baudot's work on telegraphy.]
A formula for calculating the binary pattern appearing in the $k$th position of the BRGC sequence, $k=1,..,2^n$, is given in the Wikipedia article and discussed in this StackOverflow Q&A: the nth gray code. Mathematically speaking, let $k$ be the entry we want and $g(k)$ the corresponding BRGC entry:
$$ g(k) = \lfloor (k-1)/2 \rfloor \text{ XOR } (k-1) $$
The minus 1 from $k$ is only to start the sequence with first element all zeros. If you are comfortable with 0-indexing, feel free to simplify.
It follows that many questions such as the one posed here (find neighboring entries) can be solved if an inverse to this formula is known, telling us in which BRGC position a specified binary pattern can be found. The Wikipedia article also supplies us with code for that operation, though it is less easily expressed in a single formula (but see Added below).
As a C-like looping routine:
unsigned int grayToBinary(unsigned int num)
{
unsigned int mask;
for (mask = num >> 1; mask != 0; mask = mask >> 1)
{
num = num ^ mask;
}
return num+1;
}
This differs from the Wikipedia snippet only in adding 1 to the return value, consistent with what we discuss above about 1-indexing vs. 0-indexing of the BRGC sequence.
That is, given a binary pattern g of width that fits in an unsigned integer, we can call the routine k = grayToBinary(g). The return value k or $k$ can then be incremented/decremented to produce the successor/predecessor BRGC entries by applying the formula previously cited.
Note that the code snippet does not reference the entry widths $n$ of the binary patterns. This is possible because the BRGC sequences of different widths agree on (conserve) common initial segments (an easy consequence of the recursive definition).
Added:
I implemented the coding (index to Gray code) formula and decoding (Gray code to index) routine above in a spreadsheet (to make sure I hadn't committed an obscure error), and they both worked.
We could write the decoding as a formula if only we had a symbol for accumulating bitwise exclusive-or in a manner like $\Sigma$ accumulates summation. For no particular reason other than it looks cool to me, I'll nominate $\Xi$ for this purpose. After all, bitwise exclusive-or on unsigned (nonnegative) integers is associate and commutative, so an iterated XOR makes as much sense as iterated sums or products. Then we could locate the index of bit pattern $m$ as follows:
$$ g^{-1}(m) = 1 + \operatorname{\Xi}\limits_{j=0}^{\lfloor \log_2 m \rfloor} \left\lfloor \frac{m}{2^j} \right\rfloor $$