Book
Infinite* colours
Infinite* colours
Completion requirements
View
Analog values as output in the colour spectrum.
6. Hex colours
Colours in programming are often represented as a 'hex' number. For example the colour red has the number #FF0000. You can find the numbers associated
with a particular colour using tables like these:
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.
Let's try and make the color indigo (#4B0082).
The red, green and blue parts of indigo are (in hex) 4B, 00 and 82 respectively. We can plug those into the 'setColor' function like this:
setColor(0x4B, 0x0, 0x82); // indigo
We have used hex numbers for the three parts of the color by putting '0x' in front of them.
Try adding a few colors of your own to the 'loop' function. Don't forget to add a delay after each one.
Try adding a few colors of your own to the 'loop' function. Don't forget to add a delay after each one.