SN74HC138N 3-Line to 8-Line Decoders/Demultiplexers

Used Products:

1. Arduino UNO
2. SN74HC138N

Code:

#define aPin 2 #define bPin 3 #define cPin 4 #define del 300 int matrix[][3] = { {0,0,0}, {0,0,1}, {0,1,0}, {0,1,1}, {1,0,0}, {1,0,1}, {1,1,0}, {1,1,1} }; void setup() { pinMode(aPin, OUTPUT); pinMode(bPin, OUTPUT); pinMode(cPin, OUTPUT); } void loop() { for (int i = 0; i < 8; i++) { digitalWrite(aPin, matrix[i][2]); digitalWrite(bPin, matrix[i][1]); digitalWrite(cPin, matrix[i][0]); delay(del); } }