       while (true)
       {
         tcs.getRawData(&r, &g, &b, &c); //get env info
+        bool rChange = false;
         if (r > r_h)
         {
+          rChange = true;
           r_h = r;
           if (b_h < b)
           {
             b_h = b;
           }
         }
-        else if (g > g_h)
+        if (g > g_h)
         {
           g_h = g;
           if (b_h < b)

    Serial.println("Please enter a number between 0 and 7!!");
}


            g_h = g;
          }
        }
        else if (rNotChage)
        {
          th_Val[5].r_t = ((float) r_h * thErrON);
          th_Val[5].g_t = ((float) g_h * thErrOFF);
