facing issue with while loop I'm trying to develop one code in which I'm facing issue with while loop. Once I enter any newString it enter in while loop it count till 10 times, when (n>10)  then it is coming out from the while loop.
Facing issues in this part

while (n &lt; 10)
  {
    while (!ret) {
      if ((time + 15) &lt; millis()) {
        ret = dmd.stepMarquee(-1,0);
        time = millis();
      }
    }
     ret = false;
     n++;
    }


I just want when I enter any newString when loop is running it break while loop and start display newString.

Please help me out with this. Thanks for your help, greatly appreciated.

Here is my full code:

#include &lt;SPI.h&gt;
#include &lt;DMD.h&gt;
#include &lt;TimerOne.h&gt;
#include "SystemFont5x7.h"
#include "Arial_black_16.h"

//Fire up the DMD library as dmd
#define DISPLAYS_ACROSS 2
#define DISPLAYS_DOWN 1
DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);

String inputString = "";
boolean stringComplete = false;
String commandString = "";


void ScanDMD()
{ 
  dmd.scanDisplayBySPI();
}


void setup()
{
   Serial.begin(9600);
   Serial.println("Arduino Start");
   Timer1.initialize( 5000 );
   Timer1.attachInterrupt( ScanDMD );
   dmd.clearScreen( true );
}

void loop() {

if(stringComplete)
{
  stringComplete = false;
  getCommand();

  if(commandString.equals("STAR"))
  {
   dmd.clearScreen( true );
  }

  else if(commandString.equals("PRSC"))
  {
    String text = getTextToPrint();
    printText(text);
  }
  inputString = "";
}

}


void getCommand()
{
  if(inputString.length()&gt;0)
  {
     commandString = inputString.substring(1,5);
  }
}


String getTextToPrint()
{
  String value = inputString.substring(5,(inputString.length())-2);
  return value;
}

void printText(String text)
{
  char newString[256];
  int sLength = text.length();
  text.toCharArray( newString, sLength+1 );
  dmd.selectFont(System5x7);
  dmd.drawMarquee( newString , sLength , (32*DISPLAYS_ACROSS )-1 ,1);
  unsigned long time;
  boolean ret = false;
  time = millis();
  int n;
  n= 0;
  while (n &lt; 10)
  {
    while (!ret) {
      if ((time + 15) &lt; millis()) {
        ret = dmd.stepMarquee(-1,0);
        time = millis();
      }
    }
     ret = false;
     n++;
    }
} 

void serialEvent() {        
  while (Serial.available()) {            // get the new byte:
    char inChar = (char)Serial.read();    // add it to the inputString:
    inputString += inChar;                // if the incoming character is a newline, set a flag
    // so the main loop can do something about it:
    if (inChar == '\n') {
      stringComplete = true;
    }
  }
}
Forget using serialEvent(). It is one of the more stupid things that Arduino implemented.  It is nothing more than a function that gets called (wrapped in a check to Serial.available()) once per iteration of the main loop() function.

It is not really an "event" function at all. 

To have anything happen inside your while loop you have to manually implement that thing within your while loop.  Nothing outside of the while loop (with the exception of interrupts) can affect the operation of the while loop.