Skip to main content

Digital signal and Gray code

Short answer

A digital signal has discrete levels (typically 0 and 1) that change at discrete times. Gray code is an unweighted reflected binary code where consecutive numbers differ by one bit; e.g., binary 1101 → Gray 1011. Used in encoders and K-maps.

Define digital signal and explain Gray code with example.

Digital signal

A digital signal is a signal that has only a finite number of discrete values (usually two levels, 0 and 1) and changes at discrete instants of time. Example: clock pulses and data in a computer.

Gray code

Gray code is an unweighted binary code in which two consecutive numbers differ in only one bit. It is also called the reflected binary code, because the code for nn bits is built by writing the (n−1)(n-1)-bit code, reflecting it like a mirror, and prefixing 0 to the top half and 1 to the bottom half.

 1-bit   2-bit    3-bit
  0       00       000
  1       01       001
 ---      11       011
 mirror   10       010
         ----      110
         mirror    111
                   101
                   100
DecimalBinaryGray
0000000
1001001
2010011
3011010
4100110
5101111
6110101
7111100

Binary to Gray: keep the MSB; Gi=Bi+1⊕BiG_i = B_{i+1} \oplus B_i. Example: (1101)2(1101)_2 → 1, 1⊕1 = 0, 1⊕0 = 1, 0⊕1 = 1 → (1011)Gray(1011)_{Gray}.

Gray to binary: keep the MSB; Bi=Bi+1⊕GiB_i = B_{i+1} \oplus G_i. Example: (1011)Gray(1011)_{Gray} → 1, 1⊕0 = 1, 1⊕1 = 0, 0⊕1 = 1 → (1101)2(1101)_2.

Features and uses

  • Unweighted, so not used for arithmetic.
  • Only one bit changes per step, so it avoids false readings in rotary shaft encoders.
  • Used to label K-map rows and columns (00, 01, 11, 10).
  • Used in ADCs and low-power counters.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Digital Logic chapter 1 questions →