I'm currently building a project that required the use of multiple 7 segment LED displays. I had an LCD already attached and needed a couple of pins for other things (like switches and buttons), so using some sort of traditional hookup to the 7 segment display was out of the question (it would require 14 pins!), and the idea of using 8 pins (2 sets of BCD numbers) was less appealing as I wanted to eventually use these in 'remotes'.
Hence after reading the tutorial on the 3 wire LCD in the playground I came up with a way to use an 8 bit shift register, 2 BCD to 7 segment decoders and a 2 digit LED (and a bunch of resistors) to come up with a breakout board (pics to come)
The code for this is fairly straight forward as well:
void BCDoutput(int Number, int dataPin, int clockPin, int latchPin){
int digit1 = Number / 10; // get the ten's digit
int digit2 = Number % 10; // get the one's digit
int pattern = digit1 << 4; // shift and store the ten's digit for the display
pattern = pattern | digit2; // bitwise or the ten's digit and ones digit
shiftOut(dataPin, clockPin, MSBFIRST, (byte) pattern); // shift the pattern to the register
digitalWrite(latchPin, 1); // flick the latch to put the data on the output pins
delay(1);
digitalWrite(latchPin, 0);
}
The parts list includes the following:
- 1 anode common 2 digit LED display (mine was HP's HDSP-K511)
- 14 resistors (I had a bunch of 1.1k, but using a different value might work better)
- 2 7447 BCD to 7 segment decoders
- 1 4094 8 stage shift and store register
- 3 16 pin DIP sockets
- 1 24 pin wide DIP socket (cut off the last 3 pins on both sides to make it fit, it was an old wire wrap socket i had laying around)
After a bit of trial and error (smallest work I have EVER done) I finally got it working!
The really neat thing is with a bit of modification you can add in as many displays as you want by connecting the Q output of one shift and store register to the data on another one.
If anyone has any suggestions let me know =)