Hi aarg, I have also this kind of display. I have uploaded you sketch, but the display stays empty (nothing on it).
aarg:
@aisc, I have written an improved driver. Can you test it for me?
// controls 4 digit 7 segment display
// test version 1
// 2015-04-22 by aarg
const byte numDigits = 4;
byte testDigit[numDigits];
// control pin definitions:
int shiftClock = 5;
int latchClock = 6;
int DIO = 7;
void setup ()
{
// configure outputs:
pinMode(shiftClock, OUTPUT);
pinMode(latchClock, OUTPUT);
pinMode(DIO, OUTPUT);
for (int i = 0; i < numDigits; i++)
testDigit[i] = i;
}
void loop()
{
displayUpdate(testDigit);
//
// any code in here that is non-blocking for more than the display
// refresh interval should not
// interfere with the display.
}
// non-blocking display update
//
// every time this routine is called, 16 bits are shifted into the display
// and latched.
// The first 8 bits is the segment data, and first 4 bits of the second byte are
// the segment select.
void displayUpdate(byte displayDigit[])
{
unsigned long lastDisplayUpdate;
const int scanRateHz = 60;
const int displayScanPeriod = 1000000L / numDigits / 8 / scanRateHz;
byte segmentList[] =
{ // 0123456789AbCdEF-
0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90, 0x8C, 0xBF, 0xC6, 0xA1, 0x86, 0xFF, 0xbf
};
static byte digit = 0;
static byte segment = 0x80;
if (micros() - lastDisplayUpdate > displayScanPeriod)
{
// send segment data
for (byte i = 8; i >= 1; i--)
{
if ( i & (~segment | segmentList[displayDigit[digit]]) != 0)
digitalWrite(DIO, HIGH);
else
digitalWrite(DIO, LOW);
bitClock();
}
// send digit select data
for (byte i = 0; i < 8; i++)
{
if (i == digit)
digitalWrite(DIO, HIGH);
else
digitalWrite(DIO, LOW);
bitClock();
}
// data is now in the display shift register, so latch to LEDs
//
latchData();
// increment variables to select the next segment and possibly the next digit:
//
segment = segment >> 1;
if (segment == 0)
{
segment = 0x80;
digit++;
if (digit >= numDigits)
digit = 0;
}
// reset timer for next update:
lastDisplayUpdate = micros();
}
// else just return without doing anything
}
void bitClock()
{
digitalWrite(shiftClock, LOW);
digitalWrite(shiftClock, HIGH);
}
void latchData()
{
digitalWrite(latchClock, LOW);
digitalWrite(latchClock, HIGH);
}