Multiplexer and shift register projects

This project integrates two key ICs: the 74HC4051 analog multiplexer/demultiplexer and the 74HC165 shift register , to efficiently control an 8-button input system and a PWM-controlled LED system.
Code:
#include <Arduino.h>
// Define pins
const int buttonPin = 2;
const int ledPin = 9;
void setup() {
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop() {
if (digitalRead(buttonPin) == HIGH) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
}
Working Principle
- Button State Reading (74HC165):
- The Arduino loads parallel data from the 8-button inputs into the 74HC165 shift register.
- It then shifts out the data serially, reading each button state one by one.
- LED Control (74HC4051):
- The system loops through all 8 LEDs, using the 74HC4051 multiplexer to select which LED to control.
- If the corresponding button is pressed, it toggles the LED ON/OFF using an XOR operation.
This design is ideal for applications requiring efficient input reading and output control while minimizing pin usage on an Arduino or microcontroller.
You may also like
EmbedLab Team
Embedded systems engineer and educator. Writes weekly tutorials at EmbedLab to help beginners ship real hardware.
Related projects

Top Elegoo Arduino Kits for DIY STEM Projects in 2025
Top Elegoo Arduino Kits for DIY STEM Projects in 2025 Are you diving into the exciting world of electronics and coding? Whether you're a curious beginner, a student, or someone building spectacular DI
5 easy Arduino Projects
Description : Dive into the world of Arduino with these five beginner-friendly projects that you can simulate online! From controlling LED brightness and counting numbers on a 7-segment display to mea

Water Level Sensor with Arduino
Step-by-step Arduino tutorial: wire the water level to an Arduino UNO, upload the example sketch, and read live values on the Serial Monitor.
 — Arduino UNO tutorial cover image](/uploads/arduino-covers/tcs3200-colour-sensor-with-arduino.webp)
Interfacing 16x2 LCD with Arduino
Step-by-step Arduino tutorial: wire the tcs3200 colour to an Arduino UNO, upload the example sketch, and read live values on the Serial Monitor.
 — Arduino UNO tutorial cover image](/uploads/arduino-covers/sound-sensor-with-arduino.webp)
Interfacing 16x2 LCD with Arduino
Step-by-step Arduino tutorial: wire the sound to an Arduino UNO, upload the example sketch, and read live values on the Serial Monitor.



