I've been sent this display and I'm having some issues getting it to work.
http://www.icstation.com/product_info.php?products_id=2428#.Ux5gPfmwLYg
With the code below I'm able to write the various digits to the display and control the decimal points. However it appears that what ever the last digit is that I write to the display fills all of the LEDs. So if I write 98765432 then 2 is displayed in all of the LEDs. This thing has no documentation so I'm just trying to figure it out. It uses two 595 shift registers. Any ideas?
#define SER 11 //DATA
#define RCL 12 // LATCH
#define CLK 8 // CLOCK
// 7 segment display with segment/bit encoding of .gfedcba
// AA
// FF BB
// GG
// EE CC
// DD .
// Binary mapping for digits 0 to 9 with decimal point turned off.
// a bit value of 0 turns the segment on, a value of 1 turns it off.
byte numbers[10] = {
B11000000, B11111001, B10100100,
B10110000, B10011001, B10010010,
B10000010, B11111000, B10000000,
B10010000 };
byte space = B11111111; // space, all segements off
byte decimal = B10000000; // decimal point on bit
// Positions
byte positions[8]={1, 2, 4, 8, 16, 32, 64, 128};
void setup() {
//set pins to output so you can control the shift register
pinMode(RCL, OUTPUT);
pinMode(CLK, OUTPUT);
pinMode(SER, OUTPUT);
}
void loop() {
digitWrite(9, 0, true);
digitWrite(8, 1, true);
digitWrite(7, 2, true);
digitWrite(6, 3, true);
digitWrite(5, 4, false);
digitWrite(4, 5, true);
digitWrite(3, 6, true);
digitWrite(2, 7, true);
}
void digitWrite(int value, int pos, boolean decimalOn) {
// turn off the output so the pins don't light up
// while you're shifting bits:
digitalWrite(RCL, LOW);
shiftOut(SER, CLK, MSBFIRST, positions[pos]);
//shiftOut(SER, CLK, MSBFIRST, pos);
if(decimalOn)
shiftOut(SER, CLK, MSBFIRST, numbers[value] ^ decimal);
else
shiftOut(SER, CLK, MSBFIRST, numbers[value]);
// turn on the output so the LEDs can light up:
digitalWrite(RCL, HIGH);
}