   // printColors(r, g, b, c);
 
 
+}
+
+void updateColorView() {
+  static int oldSortingResult = -1;
+  if (sortingResult != oldSortingResult) {
+    oldSortingResult = sortingResult;
+    switch (sortingResult) {
+      case 0:
+        Serial.println("RED");
+        analogWrite(PIN_COLOR_RED, 255);
+        analogWrite(PIN_COLOR_GREEN, 0);
+        analogWrite(PIN_COLOR_BLUE, 0);
+        break;
+      case 1:
+        Serial.println("GREEN");
+        analogWrite(PIN_COLOR_RED, 0);
+        analogWrite(PIN_COLOR_GREEN, 255);
+        analogWrite(PIN_COLOR_BLUE, 0);
+        break;
+      case 2:
+        Serial.println("YELLOW");
+        analogWrite(PIN_COLOR_RED, 255);
+        analogWrite(PIN_COLOR_GREEN, 255);
+        analogWrite(PIN_COLOR_BLUE, 0);
+        break;
+      case 3:
+        Serial.println("PURPLE");
+        analogWrite(PIN_COLOR_RED, 128);
+        analogWrite(PIN_COLOR_GREEN, 32);
+        analogWrite(PIN_COLOR_BLUE, 128);
+        break;
+      case 4:
+        Serial.println("ORANGE");
+        analogWrite(PIN_COLOR_RED, 255);
+        analogWrite(PIN_COLOR_GREEN, 128);
+        analogWrite(PIN_COLOR_BLUE, 32);
+        break;
+      default:
+        Serial.println("Unknown color");
+        analogWrite(PIN_COLOR_RED, 0);
+        analogWrite(PIN_COLOR_GREEN, 0);
+        analogWrite(PIN_COLOR_BLUE, 0);
+        break;
+    }
+  } else {
+    // Check if the color view signal has lasted enough time
+    if (millis() - lastSkittleTime > C_COLOR_SIGNAL_TIME) {
+      // Set it back to black
+      analogWrite(PIN_COLOR_RED, 0);
+      analogWrite(PIN_COLOR_GREEN, 0);
+      analogWrite(PIN_COLOR_BLUE, 0);
+    }
+  }
 }
 
 void loop() {

//    Color View Red pin to diginal pin 7
//    Color View Green pin to diginal pin 9
//    Color View Blue pin to diginal pin 6
// * LCD
//    RS pin to digital pin 12
#define PIN_LCD_RS 12


#define C_HOLE_CLEAR 300 // The clear value used to determine the hole's arrival
#define C_IDEAL_CLEAR 96 // The ideal clear value for color detection
#define C_ALLOWED_COLOR_VARIANCE 64 // Allowed color variance for color detection

#define F_TOP_SERVO_TIMEOUT_ENABLED true // Enable the timeout for the top servo
#define C_TOP_SERVO_TIMEOUT 6000 // Timeout to determine if the top servo is stuck

#define C_COLOR_SIGNAL_TIME 1000 // Each Skittle gets 1s color view signal

#define F_CALIBRATING false // Is calibration in progress



// Include libraries
#include <LiquidCrystal.h>      // LCD display
