Today we are going to examine the 74HC238 decoder/demultiplexer IC. My reason for writing this was to examine another way to get more output pins when using an Arduino or compatible board. However you can use any combination of three logic lines to turn on or off eight mutually exclusive outputs. How? Let’s find out…
First of all, here is the IC:
It is also available in SO16, SSOP16, TSSOP16 and DHVQFN16 packages. What? Here is a good list of various SMD packaging types. Although my sample is from NXP, a quick search shows it is also made by Texas Instruments and ST Microelectronics. Here is the NXP data sheet. The pin layout is very simple, apart from +5V and ground, you have six pins that control the outputs, and eight output pins, however in reality you only need to control three from the microcontroller or other logic lines. Here is the pinout diagram:
To get the output pins high, you use a combination of levels on 74HC238 pins A0~A2 and possibly E3. If you leave E3 low, no outputs can be set to high. The input combination required for each output is described in this table from the data sheet:
Notice that columns with an X can be set either high or low, but you must not leave them floating, so always connect or set an X to high or low. If you need to have active low outputs (that is, outputs are high instead of low), there is the 74HC138. So now to do this in real life! Here is a demonstration schematic to use the 74HC238 with an Arduino Uno or 100% compatible board:
… and in real life:
And here is a demonstration video, using the following sketch:
Demonstrating use of 74HC238 with Arduino
John Boxall - http://tronixstuff.com/partreviews > 74HC238
16 July 2010
Y0~Y7 > 39 ohm resistor > LED (3.2V forward voltage) > ground;
A0~A2 >> Arduino digital 2~4
E1, E2 >> ground
E3 > Arduino digital 5
16 > +5V
int A0 = 2;
int A1 = 3;
int A2 = 4;
int E3 = 5;
int d = 0; // for delay
// sets all outputs to LOW
void turnOn(int outputPin)
// turns on output at pin 'outputPin'
digitalWrite(E3, HIGH); // enables outputs
void emulateKITT(int dd)
for (int i=0; i<8; i++)
for (int i=7; i>=0; --i)
void allOn(int dd)
// scans all outputs on to emulate all being on at once for 'dd' cycles
for (int j=0; j<dd; j++)
for (int i=0; i<8; i++)
As with most other ICs of this type, you can only source 25 milliamps of current from each output, so if you need more you will have to consider the use of a switching NPN transistor etc. Although only one output can be high at a time, if you scan them quick enough, you can create the illusion that all are on at once (as in the video). Apart from LEDs and other items, you could use this IC to control stepper motors or even create a safeworking environment on a model train layout.
To conclude, the 74HC238 offers one of several ways to control more things with less control pins. Ideal for mutually exclusive outputs, however if you needed more than one high at once, the 74HC595 shift register would be the better solution. (See here for a 74HC595 tutorial).
And while you’re here – are you interested in Arduino? Buy a copy of my fantastic book “Arduino Workshop” from No Starch Press or wherever good books are sold.
In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitter, Google+, subscribe for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other – and we can all learn something.
Latest posts by John Boxall (see all)
- Add long-distance connectivity to your Arduino with the CATkit System - April 13, 2014
- Review – Intel Galileo Arduino-compatible Development Board - February 12, 2014
- Tutorial – Arduino and TFT Color Touch Screen - February 7, 2014