7 segment Alphabet

A surprisingly large amount of the ASCII table can be represented with a 7-segment display. The image here shows what can be created.

ascii7segdisp2.jpg

Here is the source code of the table used to create this.


#define SEGA 0x01
#define SEGB 0x02
#define SEGC 0x04
#define SEGD 0x08
#define SEGE 0x10
#define SEGF 0x20
#define SEGG 0x40

#define NUM0 SEGA+SEGB+SEGC+SEGD+SEGE+SEGF
#define NUM1 SEGB+SEGC
#define NUM2 SEGA+SEGB+SEGG+SEGE+SEGD
#define NUM3 SEGA+SEGB+SEGG+SEGC+SEGD
#define NUM4 SEGF+SEGG+SEGB+SEGC
#define NUM5 SEGA+SEGF+SEGG+SEGC+SEGD
#define NUM6 SEGA+SEGF+SEGE+SEGD+SEGC+SEGG
#define NUM7 SEGA+SEGB+SEGC
#define NUM8 SEGA+SEGB+SEGC+SEGD+SEGE+SEGF+SEGG
#define NUM9 SEGG+SEGF+SEGA+SEGB+SEGC+SEGD

const unsigned char asciibitmap[]={
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /*0 to 15 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 16 to 31 */
0,0,0,0,0,0,0,0,0,0,0,0,0,SEGG,0,0, /* 32 to 47 */
NUM0, NUM1, NUM2, NUM3, NUM4, NUM5, NUM6, NUM7,NUM8, NUM9, 0, 0, 0, SEGG+SEGD, 0, 0, 0, /* 48 to 64 */
SEGE+SEGF+SEGA+SEGB+SEGC+SEGG, SEGF+SEGE+SEGD+SEGC+SEGG, SEGA+SEGF+SEGE+SEGD, /* A-C */
SEGG+SEGE+SEGD+SEGC+SEGB, SEGA+SEGF+SEGG+SEGE+SEGD, SEGA+SEGF+SEGG+SEGE, /* D-F */
0, SEGF+SEGE+SEGG+SEGB+SEGC, SEGB+SEGC, SEGB+SEGC+SEGD, 0, SEGF+SEGE+SEGD, /* G-L */
0, SEGE+SEGG+SEGC, SEGA+SEGF+SEGE+SEGD+SEGC+SEGB, SEGE+SEGF+SEGA+SEGB+SEGG, 0, /* M-Q */
SEGE+SEGG, SEGA+SEGF+SEGG+SEGC+SEGD, SEGF+SEGE+SEGD+SEGG, SEGF+SEGE+SEGD+SEGC+SEGB, /* R-U */
0, 0, 0, SEGF+SEGG+SEGB+SEGC+SEGD, 0, SEGA+SEGF+SEGE+SEGD, 0, SEGA+SEGB+SEGC+SEGD, /* V-93 */
0, SEGD, 0, SEGE+SEGF+SEGA+SEGB+SEGC+SEGG, SEGF+SEGE+SEGD+SEGC+SEGG, /* 94-b */
SEGG+SEGE+SEGD, SEGG+SEGE+SEGD+SEGC+SEGB, SEGA+SEGF+SEGG+SEGE+SEGD, SEGA+SEGF+SEGG+SEGE, /* c-f */
0, SEGF+SEGE+SEGG+SEGB+SEGC, SEGC, SEGB+SEGC+SEGD, 0, SEGF+SEGE+SEGD, /* g-l */
0, SEGE+SEGG+SEGC, SEGG+SEGE+SEGD+SEGC, SEGE+SEGF+SEGA+SEGB+SEGG, 0, /* m-q */
SEGE+SEGG, SEGA+SEGF+SEGG+SEGC+SEGD, SEGF+SEGE+SEGD+SEGG, SEGE+SEGD+SEGC, /* r-u */
0,0,0, SEGF+SEGG+SEGB+SEGC+SEGD, 0}; /* v-z(122) */

To use this, just edit the first 7 lines to suit your hardware. It relies on the segments defined as shown here, but the values 0x01, 0x02, etc.. can be modified in the first 7 lines above.

seg_naming2.jpg

Then, if you want to print the ASCII character for (say) ‘H’, just write the data for asciibitmap[‘H’]. A blank character will be displayed if there is an attempt to print an unfeasible character on the 7-segment display (e.g. asciibitmap[‘K’]).

Author: admin

Leave a Reply