Making a rainbow display with the LEDs
Now we get to use these for some fun. We will extend our avoiding behavior from the previous chapter to show rainbow bar graphs on a side corresponding to the distances read. We could also use this for sensors. Before we can link the movement to the animation, how is a rainbow created?
Colour systems
RGB is how the hardware expects colors. However, RGB is less convenient for expressing intermediate colors or creating gradients between them. Colors that appear close to the eye can be a little far apart when in RGB. Because of this, there are other color systems.
The other color system we use is Hue, Saturation, and Value (HSV). We use HSV in this chapter to make rainbow-type displays and when doing computer vision in a later chapter to assist our code in detecting objects.
Hue
Imagine taking the colors of the spectrum and placing them on a circle, blending through red to orange, orange to yellow, yellow to green, green to blue...