Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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
 
Advise you on what? If you need a lookup table, use one.
 
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.

New Articles From Microcontroller Tips

Back
Top