You're currently on: Catalog » Guides » 74HC86 XOR guide: five surprising uses
The MC74HC86N puts four independent two-input XOR gates in one 14-pin chip. An XOR output is high when its inputs differ. That one rule makes the part useful well beyond a textbook logic exercise.
For each gate, 0+0→0, 0+1→1, 1+0→1 and 1+1→0 (where + means XOR, not arithmetic addition). A and B must each have a defined logic level. Gate 1 is A=pin 1, B=pin 2, Y=pin 3; the other three gates work identically.
Connect your signal to A. Hold B low and Y follows A; hold B high and Y becomes the opposite of A. This is useful for choosing active-high or active-low control in a DIY board. B needs a defined switch or logic signal, never an unconnected pin.
Feed one bit into A and another into B. Y=1 says they are different; Y=0 says they match. To compare several bits, use one XOR per bit and combine the outputs with a separate OR function. XOR alone does not give a multi-bit equality result.
Cascade three gates: P=(D0 XOR D1) XOR (D2 XOR D3). P is the even-parity bit for four data bits: adding P makes the total number of 1s even. On reception, XOR the four data bits and received P; 1 signals an odd number of bit errors. Even numbers of flipped bits can escape this check.
With binary inputs A and B, SUM=A XOR B. A separate AND gate supplies CARRY=A AND B. Thus the 74HC86 provides the sum, not the whole half-adder by itself. For multi-bit addition you also need carry handling.
Feed two clean, same-frequency digital square waves into A and B. Y is high whenever their levels differ, so its duty cycle changes with relative phase. An external low-pass filter can turn that duty cycle into an approximate voltage. This simple detector cannot tell which signal leads, and its output is ambiguous for some phase relationships; it is not a complete PLL.
For the stocked MC74HC86N (Motorola N-suffix plastic DIP), pin 14 is VCC and pin 7 is GND. The four gates are 1/2→3, 4/5→6, 9/10→8 and 12/13→11. The figure is a top view: orient the package notch upwards before counting. Do not substitute a different XOR IC pinout without checking its own sheet.
For a first DIY test, use a regulated 5 V supply and place a 100 nF ceramic bypass capacitor near pins 14 and 7. Put two switches or logic sources with defined high/low levels on pins 1 and 2; observe pin 3 with a logic probe or a suitably current-limited LED driver. Tie all other inputs to a defined level and leave unused outputs open. Never connect an output straight to an LED, motor or higher-voltage signal without checking current/level limits. The original Motorola sheet specifies a 2–6 V operating range, but HC inputs are CMOS-level: a 5 V TTL-high signal is not automatically guaranteed to meet the HC high threshold. Check the actual supply, source levels and loading.
For a broader DIY computer, the 74HC138 address-decoding guide shows how logic selects a chip, and the 6502 parts guide puts the logic in context.
See the MC74HC86N product.
Pinout, truth table, supply range and logic-level reference: original Motorola MC54/74HC86 datasheet. PDF.
We use cookies to provide you with the best possible experience. They also allow us to analyze user behavior in order to constantly improve the website for you.