R – Red, G – Green, B – Blue, basic display component to display color. We call this as one pixel for all display unit, such as monitor, TV and smart phone. It contains three inputs for red, green and blue, as well as a common ground(1). When we apply ‘analog’ voltage(2) to each corresponding pin, it will display the corresponding scale of the color. For Arduino, it can provide 0-255 scale of ‘analog’ voltage to the pin, i.e. we can get 256 different color scales of red, green or blue. If we put them together, it will give 256x256x256 = 16,777,216 colors!
(1) Do you know common anode and common cathode? see our separated post.
(2) Arduino analog output is generated by using PMW, check here to learn more.
void loop() { analogWrite (red, 255); analogWrite (green, 0); analogWrite (blue, 0); delay(1000); analogWrite (red, 0); analogWrite (green, 255); analogWrite (blue, 0); delay(1000); analogWrite (red, 0); analogWrite (green, 0); analogWrite (blue, 255); delay(1000); analogWrite (red, 0); analogWrite (green, 0); analogWrite (blue, 0); delay(1000); analogWrite (red, 255); analogWrite (green, 255); analogWrite (blue, 255); delay(1000); analogWrite (red, 232); analogWrite (green,97); analogWrite (blue, 0); delay(1000); analogWrite (red, 255); analogWrite (green,0); analogWrite (blue, 255); delay(1000); }
Black | White | Red | Green | Blue | Orange | Purple | |
R | 0 | 255 | 255 | 0 | 0 | 232 | 255 |
G | 0 | 255 | 0 | 255 | 0 | 97 | 0 |
B | 0 | 255 | 0 | 0 | 255 | 0 | 255 |
Since we need to provide ‘analog’ voltage to the RGB LED, we must be using port with ‘analog’ output support that you can see ‘~’ next to the port number, so that you can write 0 – 255 to the port to control color scale to generate different color and achieve different colors combination. Refer to above table for examples of color combination (we call this color code) or the link to a color code web site. All the color is the combination of RGB in term of hexadecimal number, e.g. #FF is 255, color code of red is #FF0000, color code of Orange is #E86100 where #E8 = 232, #61 = 97, #00 = 0.
What is pixel?
HD? 2K? 4K and 8K? When we talk about the monitor or TV, it’s quality is always related to the screen resolution, the higher resolution, more pixels, higher density, the better of the screen quality. For a 8K TV, it contains more than 33million tiny and very high quality RGB LED!!! That’s not easy to produce with good yield, that’s why it is very expensive!!!
X | Y | Total Pixels | |
Full HD | 1920 | 1080 | 2,073,600 |
2K | 2560 | 1440 | 3,686,400 |
4K | 3840 | 2160 | 8,294,400 |
8K | 7680 | 4320 | 33,177,600 |