8x32 LED matrix with 74HC154

Status
Not open for further replies.

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void display_numeric_test()
{
unsigned char data_display[4];
 
      if (UCSRA & 0x80)
      {
        data_display[0]=data_display[1];
        data_display[1]=data_display[2];
        data_display[2]=data_display[3];
        data_display[3]=UDR;
      }
 
      display_character_pattern(data_display[0],data_display[1],data_display[2],data_display[3]);
      display_clear();
 }

 

Friend, what's UDR and UCSRA ?

---------- Post added at 10:45 ---------- Previous post was at 10:44 ----------

I created like this :
Code:
serial_char=Serial_read();
	   serial_send(serial_char);
	   switch(serial_char)
	       {
		         
				 case 'a':
				     //clear_screen();
		                display_spectrum();
		             break;
		         case 'r':
		             display_numeric();
		            break;
            }

I want to display for example : a is A and r is R but in order depend on data being sent on the serial line....
so for this one X X X A then X X A R....continue followng the character in serial line...
 


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
void display_numeric_test()
{
unsigned char data_display[4];
      if (RI)
      {
        RI=0;
        data_display[0]=data_display[1];
        data_display[1]=data_display[2];
        data_display[2]=data_display[3];
        data_display[3]=SBUF;
      }
      display_character_pattern(data_display[0],data_display[1],data_display[2],data_display[3]);
 }

 

Thanks I will try it......
 

do I need to convert SBUF first before displaying ?
SBUF = which character ? related with :
Code:
display_character_pattern(33,15,21,30)
 

first condition, data_display[0]=X, data_display[1]=X, data_display[2]=X, data_display[3]=X.
after receive data 33 from PC => data_display[0]=X, data_display[1]=X, data_display[2]=X, data_display[3]=33.
after receive data 15 from PC => data_display[0]=X, data_display[1]=X, data_display[2]=33, data_display[3]=15.
after receive data 21 from PC => data_display[0]=X, data_display[1]=33, data_display[2]=15, data_display[3]=21.
after receive data 30 from PC => data_display[0]=33, data_display[1]=15, data_display[2]=21, data_display[3]=30.
 


in PC using Visual C++ I wrote like this :
Code:
case 2:
						try
		                 {
                          
			 					 MatrixLED->Open();
								 this->label1->Text = "Connected";
								 MatrixLED->WriteLine("r");
				                 x = MatrixLED->ReadLine();
								 this->label1->Text = x;
								 MatrixLED->Close();
								//this->label1->Text = "Disconnected";
						        
		                 }

so I will change WriteLine into 33 , 15 , 21 , 30, do you have idea how can I make it in sequence ? using delay ?
 

Like this ?
Code:
void display_numeric_test(){
unsigned char data_display[4];
     serial_char=Serial_read();
	 serial_send(serial_char);
      if (RI)
      {
        RI=0;
        data_display[0]=data_display[1];
        data_display[1]=data_display[2];
        data_display[2]=data_display[3];
        data_display[3]=SBUF;
      }
	  else if (RI)
      {
        RI=0;
        data_display[0]=data_display[1];
        data_display[1]=data_display[2];
        data_display[2]=SBUF;
        data_display[3]=data_display[4];
      }
      display_character_pattern(data_display[0],data_display[1],data_display[2],data_display[3]);
 }


---------- Post added at 11:04 ---------- Previous post was at 10:53 ----------

it can not accept more than one character, since it's "char" I tried to give "33" as input and can not work
Code:
unsigned char Serial_read() {
    
    SCON  = 0x50;		        /* SCON: mode 1, 8-bit UART, enable rcvr      */
    TMOD |= 0x20;               /* TMOD: timer 1, mode 2, 8-bit reload        */
	TH1 = 253;                 /* TH1:  reload value for 9600 baud @ 11.0592MHz +/- 3.5% error  */
	TL1 = 253;
	TR1   = 1;                  /* TR1:  timer 1 run                          */
        TI    = 1;                  /* TI:   set TI to send first char of UART    */
	display_wait();
	  printf("\n Enter `a` to continue \n");
        while(!RI);
        RI = 0;
        return SBUF;
}

.
.
.
serial_char=Serial_read();
	   serial_send(serial_char);
	   //display_numeric_test();
	   
	   switch(serial_char)
	       {
		   
				 case 'a':
				     //clear_screen();
		                display_character_pattern(10,10,10,15);
		             break;
		         case 'b':
                               display_character_pattern(10,10,10,16);
		            break;
            }

15 = A 16 = B, but how can I shift A to the left and display X X A B when 'b' character is being sent, and how can I make it as variable, the one I have created is fix....
do you have ideas ?
 

we can use delay after each character is sent, or use interrupt to quick handle incoming data.


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
unsigned char data_display[4];
 
void ser_int () interrupt 4
{
      if (RI)
      {
        RI=0;
        data_display[0]=data_display[1];
        data_display[1]=data_display[2];
        data_display[2]=data_display[3];
        data_display[3]=SBUF;
      }
};
 
void main ()
{
  SCON = 0x50;
  TMOD = 0x20;
  TH1  = 253;
  TR1  = 1;
  RI = 0;
  TI = 0;
  ES   = 1;
  EA   = 1;
  while (1)
  {
    display_character_pattern(data_display[0],data_display[1],data_display[2],data_display[3]);
  };
};

 

I think we miss something,
I got :
32_8_MAIN.C(307): error C205: can't call an interrupt function

---------- Post added at 08:25 ---------- Previous post was at 08:22 ----------


I put like this :
Code:
[Syntax=C]
unsigned char Serial_read() {
    
    SCON  = 0x50;		        /* SCON: mode 1, 8-bit UART, enable rcvr      */
	 SCON  = 0x52;		        /* SCON: mode 1, 8-bit UART, enable rcvr      */
    TMOD |= 0x20;               /* TMOD: timer 1, mode 2, 8-bit reload        */
	TH1 = 253;                 /* TH1:  reload value for 9600 baud @ 11.0592MHz +/- 3.5% error  */
	TL1 = 253;
	TR1   = 1;                  /* TR1:  timer 1 run                          */
    TI    = 1;                  /* TI:   set TI to send first char of UART    */
	display_wait();
	  printf("\n Enter `a` to continue \n");
        while(!RI);
        RI = 0;
        return SBUF;
}
.
.
.
unsigned char data_display[4];void display_numeric_test() interrupt 4 
{
//unsigned char data_display[4];
     
      if (RI)
      {
        RI=0;
        data_display[0]=data_display[1];
        data_display[1]=data_display[2];
        data_display[2]=data_display[3];
        data_display[3]=SBUF;
      }
	 
    
 }
.
.

 main()
{
        Serial_read();
	   display_numeric_test();
	    display_character_pattern(data_display[0],data_display[1],data_display[2],data_display[3]);
}
[/syntax]
 
Last edited:

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…