SN74LS151N (SN54/74LS151) 8-Input Multiplexer

Used Products:

1. Arduino UNO
2. SN74LS151N

Code:

int inputPins[] = {6,7,8,9,10,11,12,13}; int selectPins[] = {2,3,4}; int count = 0; void setup() { for (int i = 0; i < 3; i++) { pinMode(selectPins[i], OUTPUT); } for (int i = 0; i < 8; i++) { pinMode(inputPins[i], OUTPUT); } } void loop() { for (count = 0; count <= 7; count++) { for (int x = 0; x < 2; x++) { for (int i = 0; i <= 7; i++) { digitalWrite(inputPins[i], i==count?!(x%2==0):0); } for (int y = 0; y < 3; y++) { digitalWrite(selectPins[y], bitRead(count, y)); } delay(200); } } }