… // Based on the formula, the hue is calculated for a color that is sensed by the color sensor click board. RatioMax = MAX_FLOAT(MAX_FLOAT(RedRatio, GreenRatio), BlueRatio); RatioMin = MIN_FLOAT(MIN_FLOAT(RedRatio, GreenRatio), BlueRatio); if (RatioMax > 0) Saturation = (RatioMax - RatioMin) / RatioMax; else Saturation = 0; if (Saturation == 0) Hue = 0; else { if (RatioMax == RedRatio) Hue = (GreenRatio - BlueRatio) / (RatioMax - RatioMin); else if (RatioMax == GreenRatio) Hue = 2 + (BlueRatio - RedRatio) / (RatioMax - RatioMin); else Hue = 4 + (RedRatio - GreenRatio) / (RatioMax - RatioMin); Hue = Hue / 6; if (Hue < 0) Hue += 1; } …