Another bobble I picked up on some made-in-china electronics clearning house, this is an 8 character 7-segment (8 actually) display that uses spi to drive a chain of two 74HC595 driving two 4-packs. I'm posting the sketch I got working here because I was unable to find any example code on this specific display, or for any other 8 place display using two of that driver for that matter, and had to make one from scratch. (good learning experience for me though!)
I don't recall for certain what it cost, but it was cheap ($6 or so?) and works pretty slick. It also uses LED packs that are a good 40% smaller than the usual big ones, so it's got a cute little compactness about it for fitting into smaller project boxes, unlike say the more common (,more expensive, fewer units) DigitShield.
/*
DoFly LY-DIS00100 display demo
8 place 7 segment display
uses two 74HC595 shift registers
by N0ZYC, based on a sektch by Tom Igoe
*/
//Pin connected to latch pin (ST_CP) of first 74HC595 aka "ST"
const int latchPin = 8;
//Pin connected to clock pin (SH_CP) of first 74HC595 aka "CLK"
const int clockPin = 12;
////Pin connected to Data in (DS) of first 74HC595 aka "SER"
const int dataPin = 11;
void setup() {
//set pins to output
pinMode(latchPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
Serial.begin(115200);
delay(100);
Serial.println("reset");
delay(200);
}
// define selectable patterns here. make as many as you like actually
// although multiplexing will cause unique characters on a display to be a bit dimmer,
// it never gets worse than all 8 characters being unique, so the number of patterns
// really doesn't matter
#define pcount 18 // number of patterns. add 100 to light the decimal point on any pattern
const byte patterns[pcount] = {
0b11111100, // 0 = 0
0b01100000, // 1 = 1
0b11011010, // 2 = 2
0b11110010, // 3 = 3 // 000
0b01100110, // 4 = 4 // 5 1
0b10110110, // 5 = 5 // 5 1
0b10111110, // 6 = 6 // 666
0b11100000, // 7 = 7 // 4 2
0b11111110, // 8 = 8 // 4 2
0b11100110, // 9 = 9 // 333 (7)
0b11101110, // 10 = A
0b00111110, // 11 = B
0b10011100, // 12 = C
0b01111010, // 13 = D
0b10011110, // 14 = E
0b10001110, // 15 = F
0b00000010, // 16 = -
0b00000000 // 17 = (blank)
};
/*
first byte is the places to NOT turn on (2 turns on all but the 2nd place)
second byte is the binary coded digits in the selected places to turn on
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, 3);
shiftOut(dataPin, clockPin, MSBFIRST, 1);
digitalWrite(latchPin, HIGH);
*/
// pass in 8 character array to display
void plex(byte *got_array, unsigned long got_hold_ms) {
unsigned long done = millis()+got_hold_ms;
uint8_t placemask;
Serial.print("plexing [");
for (int i = 0 ; i < 8 ; i++) {
if (i != 0) {
Serial.print(",");
}
Serial.print(got_array[i],DEC);
}
Serial.print("] for ");
Serial.print(got_hold_ms,DEC);
Serial.println(" ms");
// wipe the display
digitalWrite(latchPin,LOW);
shiftOut(dataPin,clockPin,MSBFIRST,0);
shiftOut(dataPin,clockPin,LSBFIRST,0);
digitalWrite(latchPin,HIGH);
// program up a quick access array so the digits are lit evenly
uint8_t active=0;
byte drawmasks[pcount*2];
byte drawpats[pcount*2];
for (uint8_t pattern = 0 ; pattern < pcount ; pattern++) {
placemask=255;
for (uint8_t place = 0 ; place < 8 ; place++) {
if (got_array[7-place] == pattern) {
bitWrite(placemask,place,0);
}
}
if (placemask != 255) {
drawmasks[active]=placemask;
drawpats[active]=patterns[pattern];
active++;
}
placemask=255;
for (uint8_t place = 0 ; place < 8 ; place++) {
if (got_array[7-place]-100 == pattern) {
bitWrite(placemask,place,0);
}
}
if (placemask != 255) {
drawmasks[active]=placemask;
drawpats[active]=patterns[pattern]+1;
active++;
}
}
while (millis() < done) {
// multiplex just the patterns that are used for this array display
for (uint8_t i = 0 ; i < active ; i++) {
digitalWrite(latchPin,LOW);
shiftOut(dataPin,clockPin,LSBFIRST,drawmasks[i]);
shiftOut(dataPin,clockPin,LSBFIRST,drawpats[i]);
digitalWrite(latchPin,HIGH);
}
// and then blank out the display once for every duplicate pattern in the display
// this prevents "22222222" from being four times as bright as "11223344" because
// the former refreshes the 2s at 100% duty cycle, and the latter refreshes the 2s at 25% duty cycle
for (uint8_t i = active ; i < 8 ; i++) {
digitalWrite(latchPin,LOW);
shiftOut(dataPin,clockPin,LSBFIRST,0);
shiftOut(dataPin,clockPin,LSBFIRST,0);
digitalWrite(latchPin,HIGH);
}
}
}
// some tests to show what can be displayed and show how the display reacts to different patterns
// due to multiplexing, intensities will vary slightly depending on pattern repitition
byte test1[8] = {18,18,18,17, 0, 1, 2, 3};
byte test2[8] = {109, 8, 7, 6, 5, 4, 3, 2};
byte test3[8] = { 1,16, 2,16, 3,16, 4,17};
byte test4[8] = {16, 1, 2, 3,16, 5, 6, 7};
byte test5[8] = { 8, 9,10,11,12,13,14,15};
byte test6[8] = {108,108,108,108,108,108,108,108};
byte test7[8] = {117,117,117,117,117,117,117,117};
byte test8[8] = { 8, 1, 2, 3, 4, 5, 6, 7};
byte test9[8] = { 8, 8, 8, 8, 8, 8, 8, 8};
byte test10[8] = { 1, 1, 1, 1, 1, 1, 1, 1};
byte test11[8] = { 1,117,117,117,117,117,117,117};
void loop() {
plex(test1,2500);
plex(test2,2500);
plex(test3,2500);
plex(test4,2500);
plex(test5,2500);
plex(test6,2500);
plex(test7,2500);
plex(test8,2500);
plex(test9,2500);
plex(test8,2500);
plex(test9,2500);
plex(test10,2500);
plex(test11,2500);
}
ok not quite as cheap as I recall, but I found the link: http://www.ebay.com/itm/181216053859 - $8.60 shipped and he has some other usefull stuff.