SN54/74LS138 1-of-8 Decoder/Demultiplexer

Used Products:

1. Arduino UNO
2. SN74LS138N

Code:

#define sleep 100 int pins[3] = {2,3,4}; int matrix[][3] = { {0,0,0}, {1,0,0}, {0,1,0}, {1,1,0}, {0,0,1}, {1,0,1}, {0,1,1}, {1,1,1} }; void setup() { for (int j = 0; j < 3; j++) { pinMode(pins[j], OUTPUT); } } void loop() { for (int i = 0; i < 8; i++) { for (int j = 0; j < 3; j++) { digitalWrite(pins[j], matrix[i][j]); } delay(sleep); } }