← All parts

74HC138 3-to-8 Decoder

SN74HC138

Texas Instrumentsic logic

The 74HC138 is a high-speed CMOS 3-to-8 line decoder/demultiplexer with active-low outputs. Three select inputs and three enable inputs choose one of eight outputs, easing memory decoding and cascading.

In stock

Specifications

10
Logic Function
3-to-8 line decoder/demultiplexer
Operating Voltage
2 to 6 V
Operating Temperature Range
-40 to 85 C
Supply Current Max
80 uA
Output Drive Current
4 mA
Input Current Max
1 uA
Propagation Delay Typical
15 ns
Input Capacitance Max
10 pF
Output Current Continuous
25 mA
Package Types
SOIC-16, SSOP-16, PDIP-16, SO-16, TSSOP-16, CDIP-16, CFP-16, LCCC-20

Pinout

16
PinNameFunctionsNotes
1A
GPIO
Select input A (LSB)
2B
GPIO
Select input B
3C
GPIO
Select input C (MSB)
4G2A
GPIO
Active-low enable A
5G2B
GPIO
Active-low enable B
6G1
GPIO
Active-high enable
7Y7
GPIO
Output 7 (MSB)
8GND
GND
Ground
9Y6
GPIO
Output 6
10Y5
GPIO
Output 5
11Y4
GPIO
Output 4
12Y3
GPIO
Output 3
13Y2
GPIO
Output 2
14Y1
GPIO
Output 1
15Y0
GPIO
Output 0 (LSB)
16VCC
POWER
Supply voltage

Interactive pinout

Highlight:
SN74HC138

Click a pin to copy its name · tap a tag above to spotlight a bus.

Starter code

Community starter examples — minimal, unofficial, and provided to get you wiring fast. Verify against the manufacturer datasheet before relying on them.

Arduino (C++)

arduino
// 74HC138 3-to-8 line decoder — community starter example
// A/B/C select which ONE of Y0..Y7 goes LOW (active-low outputs).
#if defined(ESP32)
  #define A_PIN 25
  #define B_PIN 26
  #define C_PIN 27
#else
  #define A_PIN 2
  #define B_PIN 3
  #define C_PIN 4
#endif

void selectOutput(uint8_t n) {       // 0..7 -> Yn goes LOW
  digitalWrite(A_PIN, n & 1);
  digitalWrite(B_PIN, (n >> 1) & 1);
  digitalWrite(C_PIN, (n >> 2) & 1);
}

void setup() {
  pinMode(A_PIN, OUTPUT); pinMode(B_PIN, OUTPUT); pinMode(C_PIN, OUTPUT);
}

void loop() {
  for (uint8_t n = 0; n < 8; n++) { selectOutput(n); delay(200); }
}

MicroPython

python
# 74HC138 3-to-8 decoder (ESP32) — community starter example
from machine import Pin
import time

a = Pin(25, Pin.OUT); b = Pin(26, Pin.OUT); c = Pin(27, Pin.OUT)

def select(n):                       # Yn goes LOW
    a.value(n & 1); b.value((n >> 1) & 1); c.value((n >> 2) & 1)

while True:
    for n in range(8):
        select(n); time.sleep_ms(200)

Wiring

PinArduino Uno R3ESP32 DevKitC (WROOM-32)Notes
VCC+5V3V32-6 V
GNDGNDGND
AD2GPIO25Select bit 0
BD3GPIO26Select bit 1
CD4GPIO27Select bit 2
G1+5V3V3Enable: tie HIGH
G2A/G2BGNDGNDEnable: tie LOW
Y0..Y7--Selected output goes LOW (active-low)

Typical uses

  • Selecting 1 of 8 lines (chip-select, mux address)
  • Driving common-anode displays / banks

Related parts

6