If you have done any Internet programming, you will probably be aware that colors are often represented as a 'hex' number. For example the color red has the number #FF0000. You can find the numbers associated with a particular color using tables like these: https://htmlcolorcodes.com/color-names/
The six digits of the number are actually three pairs of numbers; the first pair being the red component of the color, the next two digits the green part and the final pair the blue part. Red is #FF0000, because its maximum red (FF is 255 in hex) and it has no green or blue part.
It would be pretty useful to be able to dial up one of these color numbers so that it is displayed on the RGB LED.
Let's try and make the color indigo (#4B0082).
setColor(0x4B, 0x0, 0x82); // indigo
Try adding a few colors of your own to the 'loop' function. Don't forget to add a delay after each one.
Page last edited March 08, 2024
Text editor powered by tinymce.