Projects / Address decoder with eight LEDs

Address decoder with eight LEDs

Beginner1.3 hGuided buildReviewed

Build it step by step

0 of 8 done
  1. Wire the power

    Pins 16 and 8, plus the three enable pins.

  2. 16.7 mA

    Wire the eight LEDs

    Cathodes to pins 15, 14, 13, 12, 11, 10, 9 and 7.

  3. Add the resistors

    1 kilohm from each anode to 5 V.

  4. Wire the three buttons

    To pins 1, 2 and 3 with 10 kilohm pull-downs.

  5. Power up

    Output zero is lit with no buttons pressed.

  6. Step through codes

    Press button combinations 1 to 7.

  7. Fill in the table

    Binary input and lit output.

  8. 16.8 mA

    Test the enables

    Move pin 6 to ground and watch all LEDs go out.

In short

How do you build an address decoder with eight LEDs?

Three buttons select one of eight outputs on a decoder, showing how chips pick one device out of many. You need 74HC138 3-to-8 decoder, LED 5 mm red × 8, Resistor 1 kΩ × 8, Tactile push button 6 mm × 3, Resistor 10 kΩ × 3, 5 V 2 A USB adapter, Jumper wires male to male (40 pcs, 20 cm) and Breadboard 830 Tie Points. It takes 8 steps and about 75 minutes.

Level
Beginner
Time
About 75 min
Parts
8

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
5 V adapter positiveRed railSupply
5 V adapter negativeBlue railGround
74HC138 pin 16 (VCC) and pin 8 (GND)Red rail and blue railPower
Pin 6 (G1, enable, active high)Red railEnabled
Pins 4 and 5 (G2A and G2B, active low)Blue railEnabled
Button 1Red rail to pin 1 (A0), with 10k from pin 1 to GNDLeast significant bit
Button 2Red rail to pin 2 (A1), with 10k from pin 2 to GNDMiddle bit
Button 3Red rail to pin 3 (A2), with 10k from pin 3 to GNDMost significant bit
Outputs Y0 to Y7Pins 15, 14, 13, 12, 11, 10, 9, 7Active low, one goes low at a time
Eight LEDsEach cathode to an output pin, each anode through 1 kilohm to the red railA lit LED means that output is low

Code

A decoder takes a binary number and turns on exactly one output, which is how a computer picks one memory chip or one port out of many using a few address wires. The 74HC138 has three address inputs and eight outputs, and its outputs are active low, meaning the selected output goes low while all the rest stay high. In this build the three buttons make the address, with 10 kilohm pull-downs so an input is low when the button is not pressed, and each output drives an LED that is connected to the supply, so it lights when its output is pulled low. Press button combinations and you will see the lit LED move: no buttons gives output zero, button one gives output one, buttons one and two give output three, and all three give output seven. The chip also has three enable pins, one active high and two active low, and all three must be in their enabled state for any output to go low. Move one enable and every LED goes out, which shows how enables let you join two chips into a larger decoder. CMOS outputs sink only a few milliamps, so the resistors are 1 kilohm and the LEDs are dimmer than in a microcontroller circuit. Use fresh jumper wires and keep the power at 5 volts, because the HC family has a 6 volt limit.

Build notes (no code needed for this build)

74HC138 pins: 1 A0, 2 A1, 3 A2, 4 G2A, 5 G2B, 6 G1, 7 Y7, 8 GND, 9 Y6, 10 Y5, 11 Y4, 12 Y3, 13 Y2, 14 Y1, 15 Y0, 16 VCC.

Truth table (enabled): the three inputs A2 A1 A0 form a binary number from 0 to 7, and exactly one output goes LOW:
  A2 A1 A0 = 0 0 0 -> Y0 low   0 0 1 -> Y1 low   0 1 0 -> Y2 low   0 1 1 -> Y3 low
  A2 A1 A0 = 1 0 0 -> Y4 low   1 0 1 -> Y5 low   1 1 0 -> Y6 low   1 1 1 -> Y7 low
All other outputs stay HIGH.

Because the outputs are active low, each LED is connected between the supply (through a resistor) and the output, so the LED lights when its output is low.
A CMOS output only sinks a few milliamps, so the LEDs use 1 kilohm (about 3 mA) and are a little dim.

Enable pins: the chip only decodes when G1 is high and both G2A and G2B are low. Move pin 6 to ground, or pin 4 to 5 V, and all eight LEDs go out.
Use: connect the enables to other address bits and two decoders make a 4-to-16 decoder, which is how memory chips are selected in computers.
Never leave an input floating: the 10 kilohm resistors pull each address line low until its button is pressed.

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
No buttons pressedLED 0 lit
Button 1 onlyLED 1 lit
Buttons 1 and 2LED 3 lit
All three buttonsLED 7 lit
G1 moved to groundAll LEDs off

If it does not work

Two LEDs lit

A button input is floating, check the pull-down.

No LED lit

Check the enable pins and the LED direction.

LEDs very dim

Normal with CMOS outputs, keep 1 kilohm.

Wrong LED for a code

Check the pin order of the outputs.

Chip warm

Check the supply is 5 V, not more.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the address decoder with eight LEDs?

74HC138 3-to-8 decoder, LED 5 mm red × 8, Resistor 1 kΩ × 8, Tactile push button 6 mm × 3, Resistor 10 kΩ × 3, 5 V 2 A USB adapter, Jumper wires male to male (40 pcs, 20 cm) and Breadboard 830 Tie Points.

How long does the address decoder with eight LEDs take to build?

About 75 minutes for a beginner maker, in 8 steps.

How do I know the address decoder with eight LEDs works?

No buttons pressed: LED 0 lit. Button 1 only: LED 1 lit. Buttons 1 and 2: LED 3 lit.

Two LEDs lit: what should I check?

A button input is floating, check the pull-down.

No LED lit: what should I check?

Check the enable pins and the LED direction.

LEDs very dim: what should I check?

Normal with CMOS outputs, keep 1 kilohm.

Wrong LED for a code: what should I check?

Check the pin order of the outputs.