Arduino与Proteus仿真实例-74LS138译码器驱动仿真

74LS138译码器驱动仿真

74LS138 是 TTL 逻辑门‘74xx’系列的成员。 该芯片专为解码或解复用应用而设计,具有 3 个输入到 8 个输出设置。 该设计还使芯片用于高性能存储器解码或数据路由应用,需要非常短的传播延迟时间。 在高性能存储器系统中,这些解码器可用于最小化系统解码的影响。 芯片的三个使能引脚(其中两个低电平有效,一个高电平有效)减少了扩展时对外部栅极或反相器的需要。 24线解码器无需外接反相器即可实现,32线解码器仅需一个反相器。

在前面的文章中,对74LS138译码器做了介绍,请参考:

1、仿真电路原理图

在这里插入图片描述

2、仿真代码实现

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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);
}

3、仿真结果

在这里插入图片描述

文章来源: https://iotsmart.blog.csdn.net/article/details/121316971