Look uo table

Status
Not open for further replies.

GreenP

New Member
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
 
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];
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…