LCD- Merged 2 sketches serial display and rgb cycle but timing problem

I have and lcd module 16x2 with a RGB backlight
I have merged two sketches RGB Cycle and Serial display,(the one that comes with 0022)
Each sketch works fine on its own, but with the the 2 merged
when I try to write something to the lcd, it will only print the text at the
beginning of the RGB cycle. When I try to print new text it will print the new text
and wipe the old text, but only at the start of the RGB cycle again
Can anybody see a problem?
Do I have something out of order?
Am I missing code?

/*This version is modified 3/1/11
  LiquidCrystal Library - Serial Input
 
 Demonstrates the use a 16x2 RGB Backlit LCD display.
 The LiquidCrystal library works with all LCD displays
 that are compatible with the  Hitachi HD44780 driver. 
 There are many of them out there, and you
 can usually tell them by the 16-pin interface.
 This LCD has 18 pins, extra pins are for the additional
 backlight colors of the LCD
 
 This sketch displays text sent over the serial port 
 while the RGB backlight cycles through colors.
 (e.g. from the Serial Monitor) on an attached LCD.
 
 The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * 10K potentiometer:
     --ends to +5V and ground
     --wiper to LCD VO pin (pin 3)
 * RGB Backlight RED   to digital pin 10
 * RGB Backlight GREEN to digital pin 9
 * RGB Backlight BLUE  to digital pin 6
 
 Backlight code  from Matthew L Beckler
 
 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (http://www.ladyada.net)
 example added 9 Jul 2009
 by Tom Igoe 
 modified 22 Nov 2010
 by Tom Igoe
 
 This example code is in the public domain.
 
 http://www.arduino.cc/en/Tutorial/LiquidCrystal
 */

// include the library code:
#include <LiquidCrystal.h>

int redPin = 6;  //start of RGB cycle
int bluePin = 10;
int greenPin = 9;

int redIn = 0;
int greenIn = 1;
int blueIn = 2;

int redVal;
int greenVal;
int blueVal;  //RGB cycle code

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);


void setup()
{
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // initialize the serial communications:
  Serial.begin(9600);
  redVal = 255;
  greenVal = 255;
  blueVal = 255;
  update();
}
// This function updates the LED outputs.
void update()
{
  analogWrite(redPin, redVal);
  analogWrite(greenPin, greenVal);
  analogWrite(bluePin, blueVal);
}

// This function updates one of the color variables
// either getting brighter or getting dimmer.
// It also updates the outputs and delays for 10 milliseconds.
void color_morph(int* value, int get_brighter)
{
  for (int i = 0; i < 255; i++)
  {
    if (get_brighter)
      (*value)--;
    else
      (*value)++;
      
    update();
    delay(10);
  }
}
void loop()
{
  // when characters arrive over the serial port...
  if (Serial.available())
  {
    // wait a bit for the entire message to arrive
    delay(100);
    // clear the screen
    lcd.clear();
    // read all the available characters
    while (Serial.available() > 0)
    {
      // display each character to the LCD
      lcd.write(Serial.read());
    }
  }
  {
  
  // start out at black (all off)
  color_morph(&redVal,   1); // transition to red
  color_morph(&greenVal, 1); // transition to yellow
  color_morph(&redVal,   0); // transition to green
  color_morph(&blueVal,  1); // transition to aqua
  color_morph(&redVal,   1); // transition to white
  color_morph(&greenVal, 0); // transition to violet
  color_morph(&redVal,   0); // transition to blue
  color_morph(&blueVal,  0); // transition to black (all off)
}
}

The goal is to print the RGB value on the lcd as it cycles
BUT right now one problem at a time
Tim

Can anybody see a problem?

No. The code is doing exactly what you told it to do. If there is serial data to read, read it (poorly).

If there is no serial data, or all serial data has been read, go through the whole color morphing sequence.

Then, end loop, and repeat.

What is it you want to have happen? I'd guess that you think you can have the color morphing and text reading happen simultaneously, independent of each other. Not on an Arduino, you can't.

Thank you for the reply. Now I know what the problem is. I will go back to my tutorials and quit jumping ahead :)

Tim

This idea is not dead…
I see it done on youtube

different library different hardware
Real time RGB info + Color cycling

I will Make it work…

That video showed a constant string of data on line 1, and new data being written to the LCD on each pass through update().

You could change where you look for serial data, to update(), too. So the text being displayed on line 1 could change as the color changed.

If I were going to do that, I'd be sure that the serial data consisted of a start of packet markers, the data, and an end of packet marker.

I'd clear line one only when the start of packet marker arrived. I'd add new characters, to the top line, each time one was received. I'd reset the index to where to display the next character when the end of packet marker arrived.