int C = 4; // C pin of 74138 is connected to the 11th pin of arduino int B = 3; // B pin of 74138 is connected to the 12th pin of arduino int A = 2; // A pin of 74138 is connected to the 13th pin of arduino
// the setup routine runs once when you press reset: void setup() { // initialize the digital pins as an output. pinMode(A, OUTPUT); pinMode(B, OUTPUT); pinMode(C, OUTPUT); }
// the loop routine runs over and over again forever: void loop() { // Input 0 0 0 ( 0 in decimal ) in the order C B A. Output will be through Y0 digitalWrite(A, LOW); digitalWrite(B, LOW); digitalWrite(C, LOW); delay(500);
// Input 0 0 1 ( 1 in decimal ) in the order C B A. Output will be through Y1 digitalWrite(A, HIGH); digitalWrite(B, LOW); digitalWrite(C, LOW); delay(500);
// Input 0 1 0 ( 2 in decimal ) in the order C B A. Output will be through Y2 digitalWrite(A, LOW); digitalWrite(B, HIGH); digitalWrite(C, LOW); delay(500);
// Input 0 1 1 ( 3 in decimal ) in the order C B A. Output will be through Y3 digitalWrite(A, HIGH); digitalWrite(B, HIGH); digitalWrite(C, LOW); delay(500);
// Input 1 0 0 ( 4 in decimal ) in the order C B A. Output will be through Y4 digitalWrite(A, LOW); digitalWrite(B, LOW); digitalWrite(C, HIGH); delay(500);
// Input 1 0 1 ( 5 in decimal ) in the order C B A. Output will be through Y5 digitalWrite(A, HIGH); digitalWrite(B, LOW); digitalWrite(C, HIGH); delay(500);
// Input 1 1 0 ( 6 in decimal ) in the order C B A. Output will be through Y6 digitalWrite(A, LOW); digitalWrite(B, HIGH); digitalWrite(C, HIGH); delay(500);
// Input 1 1 1 ( 7 in decimal ) in the order C B A. Output will be through Y7 digitalWrite(A, HIGH); digitalWrite(B, HIGH); digitalWrite(C, HIGH); delay(500); }