Evan Rust
Published © GPL3+

How to Use a Multiplexer to Expand IO

Use a multiplexer IC to break out four GPIO pins into 16 outputs. Perfect for an ATtiny project!

IntermediateFull instructions provided6 hours10,442

Things used in this project

Hardware components

CD74HC4067
×1
ATtiny85
Microchip ATtiny85
×1
0805 LED
×16
220 ohm Resistor 0805
×16
Slide Switch, SPDT-CO
Slide Switch, SPDT-CO
×1

Software apps and online services

Arduino IDE
Arduino IDE
Eagle

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Schematic

Board Schematic

Code

ATTiny85 Code

C/C++
const uint8_t ctrl_pins[] = {4, 2, 1, 0};

const uint8_t com_pin = 3;

void setup() {
  // put your setup code here, to run once:

  for(int pin=0; pin<4; pin++){
    pinMode(ctrl_pins[pin], OUTPUT);
    digitalWrite(ctrl_pins[pin], 1);
  }

  pinMode(com_pin, OUTPUT);
  digitalWrite(com_pin, 1);

delay(1000);

}

void loop() {
  // put your main code here, to run repeatedly:
  for(int num=0; num<16; num++){
    for(int pin=0; pin<4; pin++){
      digitalWrite(ctrl_pins[pin], (_BV(pin) & num) && 1);
    }
    delay(1000);
  }
}

Credits

Evan Rust

Evan Rust

122 projects • 1091 followers
IoT, web, and embedded systems enthusiast. Contact me for product reviews or custom project requests.

Comments