Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

8x32 LED matrix with 74HC154

Status
Not open for further replies.

bianchi77

Advanced Member level 4
Joined
Jun 11, 2009
Messages
1,313
Helped
21
Reputation
44
Reaction score
20
Trophy points
1,318
Location
California
Activity points
9,442
Guys,

How can I display a character in C for AT89S52 with 74HC154 ?

So far I can scan the matrix with this code
Code:
  row = 0xFF;
     
     for (j=0x00; j<=0x0F; j++)
	 {
		  E1=0;
		  E2=1;
		  P1 = j;
		  P2 = row;
		                           /* Output to LED Port */
	      for (i = 0; i < 10000; i++) 
		   {  /* Delay for 10000 Counts */
	       wait ();                       /* call wait function */
		  
	       }
     }

I have no idea yet on how to display one character on to the matrix....

Any ideas ?

Thanks
 

you must have all complete character database and insert it to your program.
this is just for the example, you can modify it for your real application.



Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const unsigned char flash font_7_6 [60]=
{
  0x3E,0x00,0x23,0x42,0x0C,0x72,0x1E,0x40,0x36,0x31,            //data for col 1
  0x45,0x21,0x45,0x41,0x14,0x51,0x29,0x47,0x49,0x49,            //data for col 2
  0x49,0x7F,0x49,0x49,0x24,0x51,0x49,0x48,0x49,0x49,            //data for col 3
  0x51,0x01,0x49,0x59,0x7F,0x51,0x49,0x50,0x49,0x4A,            //data for col 4
  0x3E,0x00,0x31,0x66,0x04,0x4E,0x46,0x60,0x36,0x3C,            //data for col 5  
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00             //empty, space between each char. 
};
 
 
//assume we want to display 572 (if only three chars)
 
 
unsigned char display [3] = 5,7,2;                // we can modify value of this variable in run time
 
for (x=0;x<3;x++)               //3 characters
{
  for (y=0;y<6;y++ )        //each character contains 6 cols. 
  { 
    E1=0;
    E2=1;
    P1=(x*6)+y;
    a=(y*10)+display[x];
    P2 = font[a];
    delay_ms(1);        //best refresh rate 50 Hz = 20 ms, so for each col = 20/18 ms
                    //call delay function or make it by yourself 
  };
};




Hope it can help you.
 
Last edited by a moderator:

Thanks a lot mate,

I'm gonna try..

you must have all complete character database and insert it to your program.
this is just for the example, you can modify it for your real application.


const unsigned char flash font_7_6 [60]=
{
0x3E,0x00,0x23,0x42,0x0C,0x72,0x1E,0x40,0x36,0x31, //data for col 1
0x45,0x21,0x45,0x41,0x14,0x51,0x29,0x47,0x49,0x49, //data for col 2
0x49,0x7F,0x49,0x49,0x24,0x51,0x49,0x48,0x49,0x49, //data for col 3
0x51,0x01,0x49,0x59,0x7F,0x51,0x49,0x50,0x49,0x4A, //data for col 4
0x3E,0x00,0x31,0x66,0x04,0x4E,0x46,0x60,0x36,0x3C, //data for col 5
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 //empty, space between each char.
};


//assume we want to display 572 (if only three chars)


unsigned char display [3] = 5,7,2; // we can modify value of this variable in run time

for (x=0;x<3;x++) //3 characters
{
for (y=0;y<6;y++ ) //each character contains 6 cols.
{
E1=0;
E2=1;
P1=(x*6)+y;
a=(y*10)+display[x];
P2 = font[a];
delay_ms(1); //best refresh rate 50 Hz = 20 ms, so for each col = 20/18 ms
//call delay function or make it by yourself
};
};


Hope it can help you.


---------- Post added at 04:17 ---------- Previous post was at 04:16 ----------

I have the delay function,
I'm using timer and a loop...

you must have all complete character database and insert it to your program.
this is just for the example, you can modify it for your real application.


const unsigned char flash font_7_6 [60]=
{
0x3E,0x00,0x23,0x42,0x0C,0x72,0x1E,0x40,0x36,0x31, //data for col 1
0x45,0x21,0x45,0x41,0x14,0x51,0x29,0x47,0x49,0x49, //data for col 2
0x49,0x7F,0x49,0x49,0x24,0x51,0x49,0x48,0x49,0x49, //data for col 3
0x51,0x01,0x49,0x59,0x7F,0x51,0x49,0x50,0x49,0x4A, //data for col 4
0x3E,0x00,0x31,0x66,0x04,0x4E,0x46,0x60,0x36,0x3C, //data for col 5
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 //empty, space between each char.
};


//assume we want to display 572 (if only three chars)


unsigned char display [3] = 5,7,2; // we can modify value of this variable in run time

for (x=0;x<3;x++) //3 characters
{
for (y=0;y<6;y++ ) //each character contains 6 cols.
{
E1=0;
E2=1;
P1=(x*6)+y;
a=(y*10)+display[x];
P2 = font[a];
delay_ms(1); //best refresh rate 50 Hz = 20 ms, so for each col = 20/18 ms
//call delay function or make it by yourself
};
};


Hope it can help you.


---------- Post added at 04:22 ---------- Previous post was at 04:17 ----------

do you mean :
P2 = font[a];

is

P2 = font_7_6[a];

??

you must have all complete character database and insert it to your program.
this is just for the example, you can modify it for your real application.


const unsigned char flash font_7_6 [60]=
{
0x3E,0x00,0x23,0x42,0x0C,0x72,0x1E,0x40,0x36,0x31, //data for col 1
0x45,0x21,0x45,0x41,0x14,0x51,0x29,0x47,0x49,0x49, //data for col 2
0x49,0x7F,0x49,0x49,0x24,0x51,0x49,0x48,0x49,0x49, //data for col 3
0x51,0x01,0x49,0x59,0x7F,0x51,0x49,0x50,0x49,0x4A, //data for col 4
0x3E,0x00,0x31,0x66,0x04,0x4E,0x46,0x60,0x36,0x3C, //data for col 5
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 //empty, space between each char.
};



//assume we want to display 572 (if only three chars)


unsigned char display [3] = 5,7,2; // we can modify value of this variable in run time

for (x=0;x<3;x++) //3 characters
{
for (y=0;y<6;y++ ) //each character contains 6 cols.
{
E1=0;
E2=1;
P1=(x*6)+y;
a=(y*10)+display[x];
P2 = font[a];
delay_ms(1); //best refresh rate 50 Hz = 20 ms, so for each col = 20/18 ms
//call delay function or make it by yourself
};
};


Hope it can help you.
 

pretty good
 
  • Like
Reactions: n2roy

    n2roy

    Points: 2
    Helpful Answer Positive Rating
I'm sorry, the mistake comes from when we want to use 18 cols since 74HC154 only can support 16 cols. Please try this.



Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const unsigned char flash font_7_6 [60]=
{
0x3E,0x00,0x23,0x42,0x0C,0x72,0x1E,0x40,0x36,0x31, //data for col 1
0x45,0x21,0x45,0x41,0x14,0x51,0x29,0x47,0x49,0x49, //data for col 2
0x49,0x7F,0x49,0x49,0x24,0x51,0x49,0x48,0x49,0x49, //data for col 3
0x51,0x01,0x49,0x59,0x7F,0x51,0x49,0x50,0x49,0x4A, //data for col 4
0x3E,0x00,0x31,0x66,0x04,0x4E,0x46,0x60,0x36,0x3C, //data for col 5
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 //empty, space between each char.
};
 
unsigned char display [3] = 5,7,2; // we can modify value of this variable in run time
unsigned char a;
 
 
for (x=0;x<3;x++) //3 characters
{
  for (y=0;y<6;y++ ) //each character contains 6 cols.
  {
    a=(x*6)+y;
    if (a<16)       //only for 16 condition (0-15)
    {  
      E1=0; //CS1 and CS2 of 74HC154 chip
      P1=a;
      a=(y*10)+display[x];
      P2 = font_7_6[a];
      delay_ms(1);  //or delay_us(500); try the best view
    }
  };
};





if the code above works, now we can use two 74HC154 chips to get 32 cols display. Please try this.



Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const unsigned char flash font_7_6 [60]=
{
0x3E,0x00,0x23,0x42,0x0C,0x72,0x1E,0x40,0x36,0x31, //data for col 1
0x45,0x21,0x45,0x41,0x14,0x51,0x29,0x47,0x49,0x49, //data for col 2
0x49,0x7F,0x49,0x49,0x24,0x51,0x49,0x48,0x49,0x49, //data for col 3
0x51,0x01,0x49,0x59,0x7F,0x51,0x49,0x50,0x49,0x4A, //data for col 4
0x3E,0x00,0x31,0x66,0x04,0x4E,0x46,0x60,0x36,0x3C, //data for col 5
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 //empty, space between each char.
};
 
unsigned char display [6] = 5,7,2,1,3,4; // we can modify value of this variable in run time
unsigned char a;
 
 
for (x=0;x<6;x++) //6 characters
{
  for (y=0;y<6;y++ ) //each character contains 6 cols.
  {
    a=(x*6)+y;
    if (a<16)       //only for 16 condition (0-15)
    {  
      E1=0; //CS1 and CS2 of 74HC154 chip 1
      E2=1; //CS1 and CS2 of 74HC154 chip 2
      P1=a;
      a=(y*10)+display[x];
      P2 = font_7_6[a];
     delay_ms(1);   //or delay_us(500); try the best view
    }
    else
    {
      if (a<32)
      {
        E1=1; //CS1 and CS2 of 74HC154 chip 1
        E2=0; //CS1 and CS2 of 74HC154 chip 2
        P1=a;
        a=(y*10)+display[x];
        P2 = font_7_6[a];
       delay_ms(1); //or delay_us(500); try the best view
      };
    };
  };
};

 
Last edited by a moderator:

I'm sorry, the mistake comes from when we want to use 18 cols since 74HC154 only can support 16 cols. Please try this.


const unsigned char flash font_7_6 [60]=
{
0x3E,0x00,0x23,0x42,0x0C,0x72,0x1E,0x40,0x36,0x31, //data for col 1
0x45,0x21,0x45,0x41,0x14,0x51,0x29,0x47,0x49,0x49, //data for col 2
0x49,0x7F,0x49,0x49,0x24,0x51,0x49,0x48,0x49,0x49, //data for col 3
0x51,0x01,0x49,0x59,0x7F,0x51,0x49,0x50,0x49,0x4A, //data for col 4
0x3E,0x00,0x31,0x66,0x04,0x4E,0x46,0x60,0x36,0x3C, //data for col 5
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 //empty, space between each char.
};

unsigned char display [3] = 5,7,2; // we can modify value of this variable in run time
unsigned char a;


for (x=0;x<3;x++) //3 characters
{
for (y=0;y<6;y++ ) //each character contains 6 cols.
{
a=(x*6)+y;
if (a<16) //only for 16 condition (0-15)
{
E1=0; //CS1 and CS2 of 74HC154 chip
P1=a;
a=(y*10)+display[x];
P2 = font_7_6[a];
delay_ms(1); //or delay_us(500); try the best view
}
};
};



if the code above works, now we can use two 74HC154 chips to get 32 cols display. Please try this.


const unsigned char flash font_7_6 [60]=
{
0x3E,0x00,0x23,0x42,0x0C,0x72,0x1E,0x40,0x36,0x31, //data for col 1
0x45,0x21,0x45,0x41,0x14,0x51,0x29,0x47,0x49,0x49, //data for col 2
0x49,0x7F,0x49,0x49,0x24,0x51,0x49,0x48,0x49,0x49, //data for col 3
0x51,0x01,0x49,0x59,0x7F,0x51,0x49,0x50,0x49,0x4A, //data for col 4
0x3E,0x00,0x31,0x66,0x04,0x4E,0x46,0x60,0x36,0x3C, //data for col 5
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 //empty, space between each char.
};

unsigned char display [6] = 5,7,2,1,3,4; // we can modify value of this variable in run time
unsigned char a;


for (x=0;x<6;x++) //6 characters
{
for (y=0;y<6;y++ ) //each character contains 6 cols.
{
a=(x*6)+y;
if (a<16) //only for 16 condition (0-15)
{
E1=0; //CS1 and CS2 of 74HC154 chip 1
E2=1; //CS1 and CS2 of 74HC154 chip 2
P1=a;
a=(y*10)+display[x];
P2 = font_7_6[a];
delay_ms(1); //or delay_us(500); try the best view
}
else
{
if (a<32)
{
E1=1; //CS1 and CS2 of 74HC154 chip 1
E2=0; //CS1 and CS2 of 74HC154 chip 2
P1=a;
a=(y*10)+display[x];
P2 = font_7_6[a];
delay_ms(1); //or delay_us(500); try the best view
};
};
};
};

I put

P2 = ~font[a];

and the font seems reversed
 
Last edited:

replace code :
P1=a;
with :
P1= 15 -a;

or change direction of 74HC154 output cable connection (because i see you just make it on breadboard :smile: )
 
Last edited:

replace code :
P1=a;
with :
P1= 15 -a;

or change direction of 74HC154 output cable connection (because i see you just make it on breadboard :smile: )

Ok, I will change the code....easier than changing cable

---------- Post added at 23:13 ---------- Previous post was at 22:59 ----------

If I want to change the font, just change in the font array ? which one is 5 7 and 2 ? because it seems, it's not for 8x8....one line is empty my friend...
and for number 2, it seems it's broken on top....
 

Yes, just change font array value. And the font is 7 x 5 format (7x6 = 1 col for blank)

Code:
//0	1	2	3	4	5	6	7	8	9
0x3E,	0x00,	0x23,	0x42,	0x0C,	0x72,	0x1E,	0x40,	0x36,	0x31, //data for col 1
0x45,	0x21,	0x45,	0x41,	0x14,	0x51,	0x29,	0x47,	0x49,	0x49, //data for col 2
0x49,	0x7F,	0x49,	0x49,	0x24,	0x51,	0x49,	0x48,	0x49,	0x49, //data for col 3
0x51,	0x01,	0x49,	0x59,	0x7F,	0x51,	0x49,	0x50,	0x49,	0x4A, //data for col 4
0x3E,	0x00,	0x31,	0x66,	0x04,	0x4E,	0x46,	0x60,	0x36,	0x3C, //data for col 5
0x00,	0x00,	0x00,	0x00,	0x00,	0x00,	0x00,	0x00,	0x00,	0x00 //empty, space between each char.


so, for char 2 :

Code:
0x23
0x45
0x49
0x49
0x31

        23 45 49 49 31  (hex)
bit
7	0  0  0  0  0
6	0  1  1  1  0
5	1  0  0  0  1
4	0  0  0  0  1
3	0  0  1  1  0
2	0  1  0  0  0
1	1  0  0  0  0
0	1  1  1  1  1

and it is figured as 2 (draw a line on 1's)

---------- Post added at 06:59 ---------- Previous post was at 06:25 ----------

I mean, my post contains 7x5 format, but you can change it to 8x8 format and why number 2 is broken because you still use 16 cols program and to display 3rd character at least we have to use at least 18 cols, so use 32 cols program at my last post. Please try it.
 

So if I want to display 5 in 8x8 the hex code is :
Code:
0xFF
0x80
0x80
0xFE
0x03
0x03
0x03
0xFE

What's the relation between this one and display[3]=5,7,2 ? because I only used the font for LED ??

---------- Post added at 03:38 ---------- Previous post was at 03:33 ----------

I mean, my post contains 7x5 format, but you can change it to 8x8 format and why number 2 is broken because you still use 16 cols program and to display 3rd character at least we have to use at least 18 cols, so use 32 cols program at my last post. Please try it.

Do you mean this codes below ? I have used it...and character "2" is broken as you can see at the video..

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
for (x=0;x<6;x++) //6 characters
{
for (y=0;y<6;y++ ) //each character contains 6 cols.
{
a=(x*6)+y;
if (a<16) //only for 16 condition (0-15)
{
E1=0; //CS1 and CS2 of 74HC154 chip 1
E2=1; //CS1 and CS2 of 74HC154 chip 2
P1=a;
a=(y*10)+display[x];
P2 = font_7_6[a];
delay_ms(1); //or delay_us(500); try the best view
}
else
{
if (a<32)
{
E1=1; //CS1 and CS2 of 74HC154 chip 1
E2=0; //CS1 and CS2 of 74HC154 chip 2
P1=a;
a=(y*10)+display[x];
P2 = font_7_6[a];
delay_ms(1); //or delay_us(500); try the best view
};
};
};
};

 
Last edited by a moderator:

Finally, i make a simulation on proteus, and it works.
Here i attach compressed file. I use MikroC Pro 2.2 and proteus 7.8. If you don't have proteus, I also include it with schematic (pdf) and screenshot (gif).

View attachment 69566

If I want 8x8 i replace all the 6 to 8 ?

for (y=0;y<6;y++ ) //each character contains 6 cols.
{
a=(x*6)+y;
 

If I want 8x8 i replace all the 6 to 8 ?

for (y=0;y<6;y++ ) //each character contains 6 cols.
{
a=(x*6)+y;

Yes. You're right. And you also need to build your own 8x8 font format. On my post, 7x6 format, only 6 lines at font array. So, you have make 8 lines at font array. Next, you have include all characters (letter, sign, number) to font array.
Good luck.
 

Yes. You're right. And you also need to build your own 8x8 font format. On my post, 7x6 format, only 6 lines at font array. So, you have make 8 lines at font array. Next, you have include all characters (letter, sign, number) to font array.
Good luck.

I tried with character 5 only, but it didn't show up 5, only all on in two matrix may be I need to enter more than one character ?

---------- Post added at 14:09 ---------- Previous post was at 14:06 ----------

Yes. You're right. And you also need to build your own 8x8 font format. On my post, 7x6 format, only 6 lines at font array. So, you have make 8 lines at font array. Next, you have include all characters (letter, sign, number) to font array.
Good luck.
Must I complete 0-9 font in 8x8 to make it work ?

---------- Post added at 14:41 ---------- Previous post was at 14:09 ----------

can I do like this ?
Code:
code unsigned char font[80]=
{
	0x3E,0x00,0x23,0x42,0x0C,0x72,0x1E,0x40,0x36,0x31, //data for col 1
	0x45,0x21,0x45,0x41,0x14,0x51,0x29,0x47,0x49,0x49, //data for col 2
	0x49,0x7F,0x49,0x49,0x24,0x51,0x49,0x48,0x49,0x49, //data for col 3
	0x51,0x01,0x49,0x59,0x7F,0x51,0x49,0x50,0x49,0x4A, //data for col 4
	0x3E,0x00,0x31,0x66,0x04,0x4E,0x46,0x60,0x36,0x3C, //data for col 5
	0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, //data for col 6
	0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, //data for col 7
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 //empty, space between each char.
};
Code:
	for (x=0;x<3;x++) //3 characters
			{
				for (y=0;y<8;y++ ) //each character contains 8 cols.
				{
					
					a=(x*8)+y;

I saw a strange result...
 

I tried with character 5 only, but it didn't show up 5, only all on in two matrix may be I need to enter more than one character ?
If you want to display only one character, change the line
for (x=0;x<3;x++) //3 characters
with
for (x=0;x<1;x++) //1 characters

Must I complete 0-9 font in 8x8 to make it work ?
Yes. But, if your font data only for five characters (0-4), you must change the line
a=(y*10)+display[x];
with
a=(y*5)+display[x];
or if you have complete font (ascii 0 to 127), you have to replace this line with
a=(y*128)+display[x];


can I do like this ?
....
I saw a strange result...

Your code is fine, maybe the problem is when you add font col 6 and 7 with 0xFF, so there is two vertical lines after the each number.
Or maybe you need to inverse the output as you did : P3 = ~font[a];
Or maybe you forget to change array size to 3 or more : unsigned char display[3]={5,7,2};
By the way, have you tested my attachment? Does it work with your hardware? This step has to be success before we go to next step.

About displaying 1 char, 3 char or others, my suggestion, just fix your program to the max value (for your current hardware = 4 characters in 8x8 font) and add font data with space character.
Code:
code unsigned char font[80]=
{
//0    1    2    3    4    5    6    7    8   9   10
0x3E,0x00,0x23,0x42,0x0C,0x72,0x1E,0x40,0x36,0x31,0x00, //data for col 1
0x45,0x21,0x45,0x41,0x14,0x51,0x29,0x47,0x49,0x49,0x00, //data for col 2
0x49,0x7F,0x49,0x49,0x24,0x51,0x49,0x48,0x49,0x49,0x00, //data for col 3
0x51,0x01,0x49,0x59,0x7F,0x51,0x49,0x50,0x49,0x4A,0x00, //data for col 4
0x3E,0x00,0x31,0x66,0x04,0x4E,0x46,0x60,0x36,0x3C,0x00, //data for col 5
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00, //data for col 6
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00, //data for col 7
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 //empty, space between each char.
};

When we want to display _ _ _ 8, we only need to fill the variable with 10, 10, 10, 8.
Change all 10 in the program with 11 (because now our font data contains 11 character, 0 - 10)
a=(y*10)+display[x]; >>> a=(y*11)+display[x];
 
Last edited:

If you want to display only one character, change the line
for (x=0;x<3;x++) //3 characters
with
for (x=0;x<1;x++) //1 characters


Yes. But, if your font data only for five characters (0-4), you must change the line
a=(y*10)+display[x];
with
a=(y*5)+display[x];
or if you have complete font (ascii 0 to 127), you have to replace this line with
a=(y*128)+display[x];




Your code is fine, maybe the problem is when you add font col 6 and 7 with 0xFF, so there is two vertical lines after the each number.
Or maybe you need to inverse the output as you did : P3 = ~font[a];
Or maybe you forget to change array size to 3 or more : unsigned char display[3]={5,7,2};
By the way, have you tested my attachment? Does it work with your hardware? This step has to be success before we go to next step.

About displaying 1 char, 3 char or others, my suggestion, just fix your program to the max value (for your current hardware = 4 characters in 8x8 font) and add font data with space character.
Code:
code unsigned char font[80]=
{
//0    1    2    3    4    5    6    7    8   9   10
0x3E,0x00,0x23,0x42,0x0C,0x72,0x1E,0x40,0x36,0x31,0x00, //data for col 1
0x45,0x21,0x45,0x41,0x14,0x51,0x29,0x47,0x49,0x49,0x00, //data for col 2
0x49,0x7F,0x49,0x49,0x24,0x51,0x49,0x48,0x49,0x49,0x00, //data for col 3
0x51,0x01,0x49,0x59,0x7F,0x51,0x49,0x50,0x49,0x4A,0x00, //data for col 4
0x3E,0x00,0x31,0x66,0x04,0x4E,0x46,0x60,0x36,0x3C,0x00, //data for col 5
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00, //data for col 6
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00, //data for col 7
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 //empty, space between each char.
};

When we want to display _ _ _ 8, we only need to fill the variable with 10, 10, 10, 8.
Change all 10 in the program with 11 (because now our font data contains 11 character, 0 - 10)
a=(y*10)+display[x]; >>> a=(y*11)+display[x];
Ok, thanks for the advise..
 

For example I want to display character 2, 4 times,

char 2 is
0x3C
0x42
0x81
0x01
0x0E
0x10
0x60
0xFF

Code:
code unsigned char font[32]=
{
0x3C , 0x3C , 0x3C , 0x3C 
0x42 , 0x42 , 0x42 , 0x42
0x81 , 0x81 , 0x81 , 0x81
0x0E , 0x0E , 0x0E , 0x0E
0x10 , 0x10 , 0x10 , 0x10
0x60 , 0x60 , 0x60 , 0x60
0xFF , 0xFF , 0xFF , 0xFF
}

Yes I saw two vertical lines after each number....
 

I tried to display 2

Code:
 code unsigned char font[8]=
{
	0xFF,
	0x80,
	0x80,
	0xFE,
	0x03,
	0x03,
	0x03,
	0xFE
};			 //character 2

unsigned char display [1] = {1}; // we can modify value of this variable in run time

   for (x=0;x<1;x++) //1 characters
		//for (x=0;x<3;x++) //3 characters
			{
				for (y=0;y<8;y++ ) //each character contains 8 cols.
				//for (y=0;y<6;y++ ) //each character contains 6 cols.
				{
					
					//a=(x*6)+y;
					a=(x*8)+y;
					if (a<16) //only for 16 condition (0-15)
						{ 
						    E1=0;
							P1=15-a;
							//a=(y*10)+display[x];
							a=(y*1)+display[x];
							P2 = ~font[a];
							delay_100(); //best refresh rate 50 Hz = 20 ms, so for each col = 20/18 ms
							//call delay function or make it by yourself
						}

						else
						{
							if (a<32)
							{
								E1=1; //CS1 and CS2 of 74HC154 chip 1
								E2=0; //CS1 and CS2 of 74HC154 chip 2
								P1=15-a;
								//a=(y*10)+display[x];
								a=(y*1)+display[x];
								P2 = ~font[a];
								delay_100(); //or delay_us(500); try the best view
							};
						};
				};
			};
The result :
DSCF0713.JPG
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top