G GreenP New Member Mar 12, 2009 #1 Hi Everone I am trying to implement a look up table to drive a seven segment display in C could someone please advise me? Green P
Hi Everone I am trying to implement a look up table to drive a seven segment display in C could someone please advise me? Green P
3v0 Coop Build Coordinator Forum Supporter Mar 12, 2009 #3 If you want a lookup to select which segments to light for each digit I do it like this. First define the bit needed to light each segment. Your hex values will differ from mine. Code: #define SEGA 0x20 #define SEGB 0x01 ... Then declare an array with the segments needed to construct each digit Code: const unsigned char digit[] = { SEGA | SEGB | SEGC | SEGD | SEGE | SEGF, // 0 SEGB | SEGC, // 1 SEGA | SEGB | SEGG | SEGE | SEGD, // 2 ... SEGA | SEGE | SEGF | SEGG // F } to display a '1' on a given digit set the port wired to the segments to digit[1];
If you want a lookup to select which segments to light for each digit I do it like this. First define the bit needed to light each segment. Your hex values will differ from mine. Code: #define SEGA 0x20 #define SEGB 0x01 ... Then declare an array with the segments needed to construct each digit Code: const unsigned char digit[] = { SEGA | SEGB | SEGC | SEGD | SEGE | SEGF, // 0 SEGB | SEGC, // 1 SEGA | SEGB | SEGG | SEGE | SEGD, // 2 ... SEGA | SEGE | SEGF | SEGG // F } to display a '1' on a given digit set the port wired to the segments to digit[1];