Convert HSV to RGB in Micropython


In this video lesson we showed how to convert an angle on the HSV color wheel into an RGB value that can be applied to an RGB LED. In effect, we can find a color we like on the HSV color wheel, and turn the LED in our project that color. The video above shows the framework we are using, and then derives the equations, and then develops the code. For your convenience, the code for the conversion is shown below. To make this a library, we save it as h2RGB.py on our Raspberry Pi Pico W. You can save it either in the same folder your main programs are in, or in the lib folder. To use the library, then simply import the file (h2RGB) and call the method h2RGB.getRGB(degrees), where degrees is the point on the HSV color wheel you want to convert. All of this is explained in detail in the above video.