user29796: In my recent project, I am working with serial data. Till now, I'm able to receive data and display on LCD. Now, suddenly I can't get any serial data. Nothing display on LCD.
My incoming string is:
{"Action":"ONE","TPS":"0.40","MAP":"0.95","LOAD":"14"}

And my code is below:
#include<LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 7, 6, 5, 4);

String response = "";
bool begin = false;

void setup()
{
  Serial.begin(9600);
  lcd.begin(16, 2);
}

void loop()
{

  while(Serial.available() || !begin)
  {
    char in = Serial.read();

    if (in == '{')
    {
      begin = true;
    }

    if(begin)
    {
      response += (in);
    }

    if(in == '}')
    {
        break;
    }
    delay(1);
  }

  lcd.setCursor(0, 0);
  lcd.print(response);
}


user10394: Actually I can see what I think may be an issue with your code.
 while(Serial.available() || !begin)

This isn't right.  If there is no data available in the serial buffer but the first { hasn't been seen then go and read the non-existent data anyway?  
Rather than try and explain what I mean in multiple comments I have put it all together and this is what I think your loop should be this:
/// This is un-compiled code, so you might have to fix some little issues.
/// bool begin = false;         // True when the initial { has been seen

void loop()
{
  while (finished == false)
  {
    if (Serial.available())
    {
      const char in = Serial.read();
      if (in == '{')
      {
        response = "";  // Blank the string
        begin = true;
      }
      if (begin)
      {
        response += (in); // Only write if within the {}
      }
      if (in == '}')
      { 
        begin = false;   // Prevent any chars between } and { leaking through.
        lcd.setCursor(0, 0);
        lcd.print(response);
      }
    }
    delay(1);
  }

  delay(500); // Not sure what will happen if you send multiple {} to the LCD too fast.
}


29796: <p>In my recent project, I am working with serial data. Till now, I'm able to receive data and display on LCD. Now, suddenly I can't get any serial data. Nothing display on LCD.</p>

<p>My incoming string is:</p>

<pre><code>{"Action":"ONE","TPS":"0.40","MAP":"0.95","LOAD":"14"}
</code></pre>

<p>And my code is below:</p>

<pre><code>#include&lt;LiquidCrystal.h&gt;

LiquidCrystal lcd(12, 11, 7, 6, 5, 4);

String response = "";
bool begin = false;

void setup()
{
  Serial.begin(9600);
  lcd.begin(16, 2);
}

void loop()
{

  while(Serial.available() || !begin)
  {
    char in = Serial.read();

    if (in == '{')
    {
      begin = true;
    }

    if(begin)
    {
      response += (in);
    }

    if(in == '}')
    {
        break;
    }
    delay(1);
  }

  lcd.setCursor(0, 0);
  lcd.print(response);
}
</code></pre>
 10394: <p>Actually I can see what I think may be an issue with your code.</p>

<pre><code> while(Serial.available() || !begin)
</code></pre>

<p>This isn't right.  If there is no data available in the serial buffer but the first <code>{</code> hasn't been seen then go and read the non-existent data anyway?  </p>

<p>Rather than try and explain what I mean in multiple comments I have put it all together and this is what I think your loop should be this:</p>

<pre><code>/// This is un-compiled code, so you might have to fix some little issues.
/// bool begin = false;         // True when the initial { has been seen

void loop()
{
  while (finished == false)
  {
    if (Serial.available())
    {
      const char in = Serial.read();
      if (in == '{')
      {
        response = "";  // Blank the string
        begin = true;
      }
      if (begin)
      {
        response += (in); // Only write if within the {}
      }
      if (in == '}')
      { 
        begin = false;   // Prevent any chars between } and { leaking through.
        lcd.setCursor(0, 0);
        lcd.print(response);
      }
    }
    delay(1);
  }

  delay(500); // Not sure what will happen if you send multiple {} to the LCD too fast.
}
</code></pre>
