We provide a necessary and sufficient condition for the existence of an n-bit Gray code, avoiding a given matching in the n-dimensional hypercube.