Bluetooth Led Matrix 24x8

Hi,
recently I made a 24x8 Led Matrix and now I came up with an idea to add a HC-05 bluetooth module to it so I could change text on matrix from my android phone.

Now, when I send a word from bluetooth terminal on my phone it goes on matrix pefect but, when I send another word , my matrix shows both words and when i send third word it shows all three words, and so on...

Can anybody help me how to modify the code so that the matrix shows just a word I send, not the previous one too !?
(Sorry for my bad English)

Here`s the code:

#include <SoftwareSerial.h>
int latchPin = 10;
int clockPin = 13;
int dataPin = 11;
int clock = 9;
int Reset = 8;
int latchPinPORTB = latchPin - 8;
int clockPinPORTB = clockPin - 8;
int dataPinPORTB = dataPin - 8;
int i = 0;
long scrolling_word[8];
int array_turn=0;

String Message;

int Sspeed=13;
int wc; //Character Count 
byte your_text[100][8];

char junk;


void setup()
{
Serial.begin(9600);
pinMode(dataPin,OUTPUT);
pinMode(clockPin,OUTPUT);
pinMode(latchPin,OUTPUT);
pinMode(clock,OUTPUT);
pinMode(Reset,OUTPUT);
digitalWrite(Reset,HIGH);
digitalWrite(Reset,LOW);
setupSPI();

}

//------------------------------------------------------------------------------------------------------------------------------------------
void display_word(int loops,byte word_print[][8],int num_patterns,int delay_langth){// this function displays your symbols

i = 0;// resets the counter fot the 4017

for(int g=0;g<8;g++)//resets the the long int where your word goes

  scrolling_word[g] = 0;

for(int x=0;x<num_patterns;x++){//main loop, goes over your symbols


 for(int r=0;r<8;r++)//puts the buildes the first symbol

    scrolling_word[r] |= word_print[x][r]; 

  for (int z=0;z<8;z++){//the sctolling action

      for(int p=0;p<8;p++)

        scrolling_word[p] = scrolling_word[p] << 1;

// end of the scrolling funcion

    for(int t=0;t<delay_langth;t++){// delay function, it just loops over the same display

      for(int y=0;y<8;y++){// scaning the display

        if(i == 8){// counting up to 6 with the 4017

          digitalWrite(Reset,HIGH);
          digitalWrite(Reset,LOW);
          i = 0;
        }
        latchOff();
        spi_transfer(make_word(0x01000000,y));// sending the data
        spi_transfer(make_word(0x00010000,y));
        spi_transfer(make_word(0x00000100,y));
        latchOn();
        delayMicroseconds(800);//waiting a bit
        latchOff();
        spi_transfer(0);// clearing the data
        spi_transfer(0);
        spi_transfer(0);
        latchOn();
        digitalWrite(clock,HIGH);//counting up with the 4017
        digitalWrite(clock,LOW);
        i++;
      }
    }
  }
}
finish_scroll(delay_langth);
}
//------------------------------------------------------------------------------------------------------------------------------------------
void finish_scroll(int delay_scroll){// this function is the same as the funcion above, it just finishing scrolling

for (int n=0;n<24;n++){

      for(int h=0;h<8;h++)

        scrolling_word[h] = scrolling_word[h] << 1;

    for(int w=0;w<delay_scroll;w++){
      for(int k=0;k<8;k++){
        if(i == 8){

          digitalWrite(Reset,HIGH);
          digitalWrite(Reset,LOW);
          i = 0;
        }
        latchOff();

        spi_transfer(make_word(0x01000000,k));
        spi_transfer(make_word(0x00010000,k));
        spi_transfer(make_word(0x00000100,k));
        latchOn();
        delayMicroseconds(800);

        latchOff();

        spi_transfer(0);
        spi_transfer(0);
        spi_transfer(0);

        latchOn();

        digitalWrite(clock,HIGH);
        digitalWrite(clock,LOW);
        i++;
      }
    }
  }
}
//------------------------------------------------------------------------------------------------------------------------------------------
byte make_word (long posistion,byte turn){
byte dummy_word = 0;

for(int q=0;q<8;q++){

  if(scrolling_word[turn] & (posistion<<q))
    dummy_word |= 0x01<<q;
}
return dummy_word;
}   
//------------------------------------------------------------------------------------------------------------------------------------------

void loop() {
  
  if(Serial.available()>0)
  {
while(Serial.available()>0)
  {
   char inChar = (char)Serial.read(); //read the input
  Message += inChar; //make a string of the characters coming on serial
  
  }
  Serial.println(Message);
  while (Serial.available() > 0)  
  { junk = Serial.read() ; }      // clear the serial buffer
  
    }
   display_word(1,your_text,wc,Sspeed);// calls for the display_pattern function and says that int loop = 15(if you do more loop the pattern whould scrole slower).

   updateWord (Message);

 
}
//------------------------------------------------------------------------------------------------------------------------------------------       



void latchOn(){
bitSet(PORTB,latchPinPORTB);
}

void latchOff(){
bitClear(PORTB,latchPinPORTB);
}


void setupSPI(){
byte clr;
SPCR |= ( (1<<SPE) | (1<<MSTR) ); // enable SPI as master
//SPCR |= ( (1<<SPR1) | (1<<SPR0) ); // set prescaler bits
SPCR &= ~( (1<<SPR1) | (1<<SPR0) ); // clear prescaler bits
clr=SPSR; // clear SPI status reg
clr=SPDR; // clear SPI data reg
SPSR |= (1<<SPI2X); // set prescaler bits
//SPSR &= ~(1<<SPI2X); // clear prescaler bits

delay(10);
}

byte spi_transfer(byte data)
{
SPDR = data;        // Start the transmission
while (!(SPSR & (1<<SPIF)))     // Wait the end of the transmission
{
};
return SPDR;        // return the received byte, we don't need that
}


void updateWord(String tMessage)
{

int ii;
char tempChar;
wc=tMessage.length();
for (ii=0; ii<tMessage.length();ii++)
{
tempChar=tMessage.charAt(ii);
//  
switch(tempChar)
{

  case 'A':
  your_text[ii][0]=B01110000;
  your_text[ii][1]=B10001000;
  your_text[ii][2]=B10001000;
  your_text[ii][3]=B11111000;
  your_text[ii][4]=B10001000;
  your_text[ii][5]=B10001000;
  your_text[ii][6]=B10001000;
  your_text[ii][7]=B10001000;
  break;

  case 'B':
  your_text[ii][0]=B11110000;
  your_text[ii][1]=B10001000;
  your_text[ii][2]=B10001000;
  your_text[ii][3]=B11110000;
  your_text[ii][4]=B10001000;
  your_text[ii][5]=B10001000;
  your_text[ii][6]=B10001000;
  your_text[ii][7]=B11110000;
  break; ................................
...................................
   }
}
}

In your code, how can you tell when you are reading a new word and not characters from the existing current one?

Can you tell me what should I change or add in code to make it read just the current word I send?
Thank you

Can you tell me what should I change or add in code to make it read just the current word I send?

Yes. As soon as you tell us how you are supposed to know when a word ends. As you can see from this post, the end of a word is marked by a space or other punctuation mark. What marks the end of YOUR words? If the answer is "nothing", thenyoucan'ttellwhenawordendsandanotherbegins.

I dont know what marks the end of the word...I tought the display would show just the word I sent and new word would replace the previous one.

It's you Android app sending the word. Why don't you make the app send something after the word, like a space?

Then, you could read and store the letters until the space arrives. At that point, clear the display and show the saved letters.

What should I do in my code so that when I send a word the previous one deletes and display shows new word?
Sorry if i ask stupid questions, I`m still learning programming

You generally need to have 2 word buffers - one for the current word you are displaying and another for the new word as it comes in. When you reach the end of the new word (however that is worked out) then replace the currently displayed word with the new one. You may also need to rest the buffers for the received word ready for another new word.

If it is useful, you may want to look at how it is done in my MD_Parola or MD_MAX72xx libraries (links below). I have a few examples where serial data from the monitor is displayed on a LED matrix.

could anyone post some code example?