Has anyone used the SparcFun Large Digit Driver with a photon? I’d like to develop a race timer display with digits 6.5" tall
I have no experience with that driver, but the sample code from SparkFun seems easily portable.
Yes, the SparkFun Large Digit Driver works well with the Argon. However, a level shifter will be needed to convert the Argon 3.3V signal to 5V, which I can confirm the Digit Driver requires. Here is a level shifting tutorial.
The code requires understanding of left shifting bits, such that each bit controls a light segment. I simplified and annotated the above code below.
int segmentClock = 6;
int segmentLatch = 5;
int segmentData = 4;
int y;
int x=0;
void setup()
{
pinMode(segmentClock, OUTPUT);
pinMode(segmentData, OUTPUT);
pinMode(segmentLatch, OUTPUT);
digitalWrite(segmentClock, LOW);
digitalWrite(segmentData, LOW);
digitalWrite(segmentLatch, LOW);
}
void loop()
{
postNumber(x, false); // false = don't show decimal
digitalWrite(segmentLatch, LOW);
digitalWrite(segmentLatch, HIGH); //resets storage register
x++;
if (x == 10) { x = 0;} //Reset x after 9
}
void postNumber(byte number, boolean decimal)
{
// positions on LED display
// - A
// / / F/B
// - G
// / / E/C
// -. D/DP
// define positions in terms of bytes
// 1<<4 means left shift 1 bit to position 4 (positions 0-7) = 00010000
#define a 1<<0 // byte 00000001
#define b 1<<6 // byte 01000000
#define c 1<<5 // byte 00100000
#define d 1<<4 // byte 00010000
#define e 1<<3 // byte 00001000
#define f 1<<1 // byte 00000010
#define g 1<<2 // byte 00000100
#define dp 1<<7 // byte 10000000
byte segments;
switch (number) // switch is an if-then statement to assign a byte to segments
// using | (or) to combine segments
{
case 1: segments = b | c; break; // byte 01010000
case 2: segments = a | b | d | e | g; break;
case 3: segments = a | b | c | d | g; break;
case 4: segments = f | g | b | c; break;
case 5: segments = a | f | g | c | d; break;
case 6: segments = a | f | g | e | c | d; break;
case 7: segments = a | b | c; break;
case 8: segments = a | b | c | d | e | f | g; break;
case 9: segments = a | b | c | d | f | g; break;
case 0: segments = a | b | c | d | e | f; break;
case ' ': segments = 0; break;
case 'c': segments = g | e | d; break;
case '-': segments = g; break;
}
if (decimal) segments |= dp; // use | (or) to add the dp segment to the number
for (y = 0 ; y < 8 ; y++)
{
digitalWrite(segmentClock, LOW); // tell chip to accept bits
digitalWrite(segmentData, segments & (1 << (7 - y)) ); // send one bit
// starting at left and moving right using & (and)
digitalWrite(segmentClock, HIGH); // tell chip that bit submission is complete
}
}
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.