We have already seen Controlling 74138, 3-Line to 8-Line Decoder/Demultiplexer, using Switches. Controlling 74138 using Arduino is more simpler. Circuit is done as shown in the following diagram. Here an arduino mega board is used for controlling 74138. Select pins ( A, B and C ) and enable pins ( G1, G2A and G2B ) are connected to digital pins of arduino. Connections are:
G1 pin of 74138 is connected to the 8th digital pin of arduino.
G2B pin of 74138 is connected to the 9th digital pin of arduino.
G2A pin of 74138 is connected to the 10th digital pin of arduino.
C pin of 74138 is connected to the 11th digital pin of arduino.
B pin of 74138 is connected to the 12th digital pin of arduino.
A pin of 74138 is connected to the 13th digital pin of arduino.
Pinout diagram of 74138
Pinout diagram of 74138 is given below. It has three enable pins ( G1, G2A, G2B ), three select pins ( A, B, C ) and eight output pins ( Y0 - Y7 ). Vcc is normally 5V and is supplied from Arduino board or from 7805 voltage regulator. 74138 will take data inputs through the select pins and outputs through the output pin having the number same as input. That is,
if the select pins are at L L L ( 0 in decimal ) in the order C B A, output will be through Y0.
if the select pins are at L L H ( 1 in decimal ) in the order C B A, output will be through Y1.
If the select pins are at L H L ( 2 in decimal ) in the order C B A, output will be through Y2.
If the select pins are at L H H ( 3 in decimal ) in the order C B A, output will be through Y3.
If the select pins are at H L L ( 4 in decimal ) in the order C B A, output will be through Y4.
If the select pins are at H L H ( 5 in decimal ) in the order C B A, output will be through Y5.
If the select pins are at H H L ( 6 in decimal ) in the order C B A, output will be through Y6.
If the select pins are at H H H ( 7 in decimal ) in the order C B A, output will be through Y7.
74138 always gives a complemented output. LED will turn off, if there is an output. LED will turn on, if there is no output.
Truth table of 74138
Truth table of 74138 is given below. 74138 gives inverted output. That is, LED will turn off, if there is an output through corresponding pin. If the output is HIGH ( H ), LED corresponding to that output will turn ON. Similarly, If the output is LOW ( L ), LED corresponding to that output will turn OFF.
From the truth table, it is clear that G1 should be HIGH ( H ) always. If G1 is LOW ( L ), all the outputs will be HIGH ( H ) and will not change, even if the select (A, B and C) pins change. That is, all the LEDs will turn on. Similarly, G2A and G2B should be LOW ( L ) always. Otherwise, all the outputs will be HIGH ( H ) and will not change, even if the select (A, B and C) pins change.
If G1 is HIGH ( H ), G2A is LOW ( L ) and G2B is LOW ( L ) , outputs will change with change in select pins ( A, B and C ). Changes in output with change in input is clearly given in the truth table given above.
Program
Now upload the following program to your arduino board.
int G1 = 8; // G1 pin of 74138 is connected to the 8th pin of arduino
int G2B = 9; // G2B pin of 74138 is connected to the 9th pin of arduino
int G2A = 10; // G2A pin of 74138 is connected to the 10th pin of arduino
int C = 11; // C pin of 74138 is connected to the 11th pin of arduino
int B = 12; // B pin of 74138 is connected to the 12th pin of arduino
int A = 13; // 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);
pinMode(G2B, OUTPUT);
pinMode(G2A, OUTPUT);
pinMode(G1, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(G2B, LOW); // Set G2B to LOW
digitalWrite(G2A, LOW); // Set G2A to LOW
digitalWrite(G1, HIGH); // Set G1 to HIGH
// 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(1000);
// 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(1000);
// 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(1000);
// 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(1000);
// 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(1000);
// 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(1000);
// 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(1000);
// 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(1000);
}
Output will be a running LEDs. Reduce the time delay to increase the speed of running LEDs.
G1 pin of 74138 is connected to the 8th digital pin of arduino.
G2B pin of 74138 is connected to the 9th digital pin of arduino.
G2A pin of 74138 is connected to the 10th digital pin of arduino.
C pin of 74138 is connected to the 11th digital pin of arduino.
B pin of 74138 is connected to the 12th digital pin of arduino.
A pin of 74138 is connected to the 13th digital pin of arduino.
Pinout diagram of 74138
Pinout diagram of 74138 is given below. It has three enable pins ( G1, G2A, G2B ), three select pins ( A, B, C ) and eight output pins ( Y0 - Y7 ). Vcc is normally 5V and is supplied from Arduino board or from 7805 voltage regulator. 74138 will take data inputs through the select pins and outputs through the output pin having the number same as input. That is,
if the select pins are at L L L ( 0 in decimal ) in the order C B A, output will be through Y0.
if the select pins are at L L H ( 1 in decimal ) in the order C B A, output will be through Y1.
If the select pins are at L H L ( 2 in decimal ) in the order C B A, output will be through Y2.
If the select pins are at L H H ( 3 in decimal ) in the order C B A, output will be through Y3.
If the select pins are at H L L ( 4 in decimal ) in the order C B A, output will be through Y4.
If the select pins are at H L H ( 5 in decimal ) in the order C B A, output will be through Y5.
If the select pins are at H H L ( 6 in decimal ) in the order C B A, output will be through Y6.
If the select pins are at H H H ( 7 in decimal ) in the order C B A, output will be through Y7.
74138 always gives a complemented output. LED will turn off, if there is an output. LED will turn on, if there is no output.
Truth table of 74138
Truth table of 74138 is given below. 74138 gives inverted output. That is, LED will turn off, if there is an output through corresponding pin. If the output is HIGH ( H ), LED corresponding to that output will turn ON. Similarly, If the output is LOW ( L ), LED corresponding to that output will turn OFF.
From the truth table, it is clear that G1 should be HIGH ( H ) always. If G1 is LOW ( L ), all the outputs will be HIGH ( H ) and will not change, even if the select (A, B and C) pins change. That is, all the LEDs will turn on. Similarly, G2A and G2B should be LOW ( L ) always. Otherwise, all the outputs will be HIGH ( H ) and will not change, even if the select (A, B and C) pins change.
If G1 is HIGH ( H ), G2A is LOW ( L ) and G2B is LOW ( L ) , outputs will change with change in select pins ( A, B and C ). Changes in output with change in input is clearly given in the truth table given above.
Program
Now upload the following program to your arduino board.
int G1 = 8; // G1 pin of 74138 is connected to the 8th pin of arduino
int G2B = 9; // G2B pin of 74138 is connected to the 9th pin of arduino
int G2A = 10; // G2A pin of 74138 is connected to the 10th pin of arduino
int C = 11; // C pin of 74138 is connected to the 11th pin of arduino
int B = 12; // B pin of 74138 is connected to the 12th pin of arduino
int A = 13; // 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);
pinMode(G2B, OUTPUT);
pinMode(G2A, OUTPUT);
pinMode(G1, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(G2B, LOW); // Set G2B to LOW
digitalWrite(G2A, LOW); // Set G2A to LOW
digitalWrite(G1, HIGH); // Set G1 to HIGH
// 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(1000);
// 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(1000);
// 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(1000);
// 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(1000);
// 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(1000);
// 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(1000);
// 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(1000);
// 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(1000);
}
Output will be a running LEDs. Reduce the time delay to increase the speed of running LEDs.
Great job for publishing such a nice article. Your article isn’t only useful but it is additionally really informative. we provide high quality led signs at affordable prices. for more info visit our website.
ReplyDeleteĐặt vé tại Aivivu, tham khảo
ReplyDeletevé máy bay đi Mỹ tháng nào rẻ nhất
chuyến bay cứu trợ mỹ về việt nam
vé máy bay từ canada về việt nam giá rẻ
Lịch bay từ Hàn Quốc về Việt Nam tháng 7
ACCUPLACER is a series of tests that helps to determine a student's preparedness for college-level courses. If a student wants to do well on this test then he should study our practice test. We arrange our practice test with the most possible questions that may come into the main test. Our practice test is fully free. ACCUPLACER practice test
ReplyDeleteACCUPLACER is a series of tests that helps to determine a student's preparedness for college-level courses. If a student wants to do well on this test then he should study our practice test. We arrange our practice test with the most possible questions that may come into the main test. Our practice test is fully free. ACCUPLACER practice test.so click here Cba it
ReplyDeleteVery great post. I just found your blog and needed to say that I have truly appreciated perusing your blog entries. I genuinely want to believe that you post again soon. Large gratitude for the helpful data.용인출장마사지
ReplyDelete가평출장마사지
이천출장마사지
일산출장마사지
파주출장마사지
평택출장마사지
화성출장마사지
의정부출장마사지
There are a few things to keep in mind when using a Roaming SIM card. First, it is important to check with your home network to see if they offer roaming services and what the rates are. Additionally, you will need to make sure that your phone is unlocked so that it can be used with a Roaming SIM card. Finally, keep in mind that you may incur additional charges for using data while roaming, so it is best to use a data plan if you need to stay connected. SimCard for travel
ReplyDelete양평 출장샵
ReplyDelete공주 출장샵
제천 출장샵
여수 출장샵
목포 출장샵