74238 IC: 3-Line to 8-Line Decoder/Demultiplexer
The 74238 IC is a 3-line to 8-line decoder/demultiplexer, a type of digital decoding integrated circuit (IC) commonly used in digital electronic circuits. It is designed to decode three binary inputs (A, B, and C) into eight distinct output lines (Y0 to Y7).
The 74238 IC has a 16-pin DIP (Dual In-Line Package) package. The pinout is as follows:
| Pin No. | Pin Name | Function |
| --- | --- | --- |
| 1 | A | Input ( Binary ) |
| 2 | B | Input ( Binary ) |
| 3 | C | Input ( Binary ) |
| 4 | Vcc | Power Supply ( +5V ) |
| 5 | Y0 | Output ( Active Low ) |
| 6 | Y1 | Output ( Active Low ) |
| 7 | Y2 | Output ( Active Low ) |
| 8 | Y3 | Output ( Active Low ) |
| 9 | Y4 | Output ( Active Low ) |
| 10 | Y5 | Output ( Active Low ) |
| 11 | Y6 | Output ( Active Low ) |
| 12 | Y7 | Output ( Active Low ) |
| 13 | GND | Ground |
| 14-16 | NC | No Connection |
### Example 1: Basic Decoder (Binary to Decimal)
In this example, we will use the 74238 IC to decode a 3-bit binary input into its corresponding decimal value.
Connect the input pins (A, B, and C) to three DIP switches or a 3-bit binary counter. Connect the output pins (Y0 to Y7) to eight LEDs, each representing a decimal value from 0 to 7.
```
// Define the input pins
int A = 2; // Pin 2
int B = 3; // Pin 3
int C = 4; // Pin 4
// Define the output pins
int Y0 = 5; // Pin 5
int Y1 = 6; // Pin 6
int Y2 = 7; // Pin 7
int Y3 = 8; // Pin 8
int Y4 = 9; // Pin 9
int Y5 = 10; // Pin 10
int Y6 = 11; // Pin 11
int Y7 = 12; // Pin 12
void setup() {
pinMode(A, INPUT);
pinMode(B, INPUT);
pinMode(C, INPUT);
pinMode(Y0, OUTPUT);
pinMode(Y1, OUTPUT);
pinMode(Y2, OUTPUT);
pinMode(Y3, OUTPUT);
pinMode(Y4, OUTPUT);
pinMode(Y5, OUTPUT);
pinMode(Y6, OUTPUT);
pinMode(Y7, OUTPUT);
}
void loop() {
int input = (digitalRead(A) << 2) | (digitalRead(B) << 1) | digitalRead(C);
switch (input) {
case 0:
digitalWrite(Y0, LOW);
digitalWrite(Y1, HIGH);
digitalWrite(Y2, HIGH);
digitalWrite(Y3, HIGH);
digitalWrite(Y4, HIGH);
digitalWrite(Y5, HIGH);
digitalWrite(Y6, HIGH);
digitalWrite(Y7, HIGH);
break;
case 1:
digitalWrite(Y0, HIGH);
digitalWrite(Y1, LOW);
digitalWrite(Y2, HIGH);
digitalWrite(Y3, HIGH);
digitalWrite(Y4, HIGH);
digitalWrite(Y5, HIGH);
digitalWrite(Y6, HIGH);
digitalWrite(Y7, HIGH);
break;
// ...
case 7:
digitalWrite(Y0, HIGH);
digitalWrite(Y1, HIGH);
digitalWrite(Y2, HIGH);
digitalWrite(Y3, HIGH);
digitalWrite(Y4, HIGH);
digitalWrite(Y5, HIGH);
digitalWrite(Y6, HIGH);
digitalWrite(Y7, LOW);
break;
}
delay(50); // Debounce delay
}
```
### Example 2: Demultiplexer (Channel Selection)
In this example, we will use the 74238 IC as a demultiplexer to select one of eight channels based on a 3-bit binary input.
Connect the input pins (A, B, and C) to three DIP switches or a 3-bit binary counter. Connect the output pins (Y0 to Y7) to eight channel selectors (e.g., eight SPDT switches or eight optical isolators).
```
// Define the input pins
int A = 2; // Pin 2
int B = 3; // Pin 3
int C = 4; // Pin 4
// Define the output pins
int Y0 = 5; // Pin 5
int Y1 = 6; // Pin 6
int Y2 = 7; // Pin 7
int Y3 = 8; // Pin 8
int Y4 = 9; // Pin 9
int Y5 = 10; // Pin 10
int Y6 = 11; // Pin 11
int Y7 = 12; // Pin 12
void setup() {
pinMode(A, INPUT);
pinMode(B, INPUT);
pinMode(C, INPUT);
pinMode(Y0, OUTPUT);
pinMode(Y1, OUTPUT);
pinMode(Y2, OUTPUT);
pinMode(Y3, OUTPUT);
pinMode(Y4, OUTPUT);
pinMode(Y5, OUTPUT);
pinMode(Y6, OUTPUT);
pinMode(Y7, OUTPUT);
}
void loop() {
int channel = (digitalRead(A) << 2) | (digitalRead(B) << 1) | digitalRead(C);
switch (channel) {
case 0:
digitalWrite(Y0, LOW); // Select Channel 0
digitalWrite(Y1, HIGH);
digitalWrite(Y2, HIGH);
digitalWrite(Y3, HIGH);
digitalWrite(Y4, HIGH);
digitalWrite(Y5, HIGH);
digitalWrite(Y6, HIGH);
digitalWrite(Y7, HIGH);
break;
case 1:
digitalWrite(Y0, HIGH);
digitalWrite(Y1, LOW); // Select Channel 1
digitalWrite(Y2, HIGH);
digitalWrite(Y3, HIGH);
digitalWrite(Y4, HIGH);
digitalWrite(Y5, HIGH);
digitalWrite(Y6, HIGH);
digitalWrite(Y7, HIGH);
break;
// ...
case 7:
digitalWrite(Y0, HIGH);
digitalWrite(Y1, HIGH);
digitalWrite(Y2, HIGH);
digitalWrite(Y3, HIGH);
digitalWrite(Y4, HIGH);
digitalWrite(Y5, HIGH);
digitalWrite(Y6, HIGH);
digitalWrite(Y7, LOW); // Select Channel 7
break;
}
delay(50); // Debounce delay
}
```
Note: These examples are for illustrative purposes only and may require additional circuitry or components depending on the specific application. Make sure to consult the datasheet and relevant documentation for the 74238 IC and other components used in your design.