About 15 years ago, when I was in school for Electronics, we were given a pretty large toolkit containing of all the things we'd need for the course: multimeter, breadboard, components, etc.
Within that kit of components was the usual assemblage of TTL chips: 7400, 7402, 7408, etc. The basic gates. However, there were a few other gems in there. I don't remember the other ones, but I do remember the 74154. The reason being, this chip is huge! Well, comparatively speaking. Compared to most of the other 7 or 8-pin TTL chips, this 24-pin chip is a monster! Here it is next to a 7400.
I remember asking my teacher what it did, to which he replied, "Don't worry about it. We don't use that chip in this course. It just comes with the kit.” I don't remember if I ever
Googled to see what it did, but I do know that it's been sitting in my parts organizer in a drawer marked "Random Chips" for 15 years.
I recently went through all the drawers in an attempt to better organize all my components. Also, to refresh my memory as to exactly what I have. There have been a few times I've ordered a part, to find out a few months later, I already had one.
So what is this 74154? Well, it's a 4-line to 16-line decoder/demultiplexer of course! So what's it do? Let's find out!
Looking at the data sheet, it takes a binary input and decodes it on one of the 16 outputs. If you feed it "0001" on the ABCD inputs, output 1 goes LOW. Feed it "1111", and output 15 goes LOW, etc.
Sound easy enough.
I connected 16 LEDs to the 74154's output pins and connected the ABCD inputs to my Arduino.
Here’s the hookup:
I wrote a sketch to output a binary number from 0 -15. That's really easy to do.
const int A = 2;
const int B = 3;
const int C = 4;
const int D = 5;
void setup() {
pinMode(A, OUTPUT);
pinMode(B, OUTPUT);
pinMode(C, OUTPUT);
pinMode(D, OUTPUT);
}
void loop() {
//0000 - 0
digitalWrite(A, LOW);
digitalWrite(B, LOW);
digitalWrite(C, LOW);
digitalWrite(D, LOW);
delay(1000);
//0001 - 1
digitalWrite(A, HIGH);
digitalWrite(B, LOW);
digitalWrite(C, LOW);
digitalWrite(D, LOW);
delay(1000);
//0010 - 2
digitalWrite(A, LOW);
digitalWrite(B, HIGH);
digitalWrite(C, LOW);
digitalWrite(D, LOW);
delay(1000);
//etc.....
}
Here it is in action:
Cool! It works.
I thought it would be cool to see the lights strobe back and forth like Cylon eyes, or Knight Rider's KITT.
I simply modified my sketch to count down, as well as up.
Wouldn't it be cool to be able to adjust the speed? For that, I'd need to add a potentiometer.
I modified the sketch to adjust the delay based on the analogRead value.
Awesome.
This is such a silly little thing, but I can't imagine using this chip for anything other than to mess around with some LEDs. Rather than throw it back in my parts organizer for another 15 years, I figured I might as well use it up. I'm going to throw together a quick little battery-operated PCB just to make use of this chip. It's no big deal, just a silly little LED thing.
With that said, counting to 15 in binary is sort of a waste of an ATmega328. While only needing 5 pins, this sounds like the perfect job for an ATtiny.
I modified my sketch for the ATtiny and uploaded it to my chip using my
ATtiny Programming Shield.
Here’s the hookup:
It works like a charm.
I threw together a quick PCB and sent it off to OSH Park.
The original plan was to have it run off two CR1220 coin cell batteries, but unfortunately, they just don’t have enough juice. Instead, I just connected it to a 3xAA battery pack.
Here it is in action…
This was a fun little project. A great way to kill a lazy Sunday afternoon.